While posts #2 and #6 are correct, there is an additional perspective that I found very helpful to understand.
Karanbir:
..an object has so many types of energies like energy due to mass in it, kinetic energy, pot. energy etc. So does the 'E' in E=mc2 give sum of all these energies or only the energy due to mass?...if we say E in E=mc2 is energy due to mass only, then where does the kinetic energy or pot. energy that the object had
As #6, explains, E = mc
2 applies when the momentum [p] [lateral movement] is zero. An equivalent way of looking at this is that the first part [mc
2 is the total energy in the frame of the matter particle while the second part is it's additional energy in the frame of the observer.
However, there are different types of energy in the frame of the particle. So for example, if we are considering a particle with structure, like an atom with orbital electrons, heating the atom increases the energy in the frame of the particle: the electrons move to more energetic orbitals, the structure now exhibits additional 'mass' due to this random kinetic energy. It has more 'rest mass' than a cold atom.
You can think of this as analogous to a coiled spring: In that situation energy is also contained within the structure, but there it is mostly potential energy; a coiled spring has infinitisimally more 'rest mass' than an uncoiled spring! [It also heats a bit when compressed.]
But you cannot 'heat' a fundamental matter particle, say an electron, because it has no 'structure' with which to absorb energy. No degrees of freedom like an atom. In an atom, it is the structure that absorbs heat energy, not the individual electrons themselves...they just bump up or down in orbitals of different energy levels, say as when reacting with chemical reactions. [Neutrons and protons do have structure...quarks.]
The binding energy mentioned in previous posts is also an analogous energy component, but in that case is an energy component of the nucleus rather the the orbital electrons.