Heat and temperature are one of the essential topics in IIT JEE.
Heat is a form of energy which can be generated by several processes like friction, ignition, short circuit, electricity, light energy inherently has heat, chemical reactions etc.
But you will be astonished to find that although heat generation can be mechanical, heat transfer is a non-mechanical process and it happens when two bodies with different temperature come in contact.
Heat and temperature are two different entities but are generally understood to be same, lets get out of this misconception.
The heat of a system is the total heat energy of all the molecules in the system, while temperature of a system is the average energy of all the molecules in a system.
So, if two bodies of the same material are at same temperature, then the one which has higher mass will have higher heat energy.
Now, how do we decide where will heat flow if the above mentioned two bodies are in contact?
Answer: heat energy of bodies is not the deciding factor for heat flow, heat flows from the body at higher temperature to body at lower temperature.
It's like this if there are two friend countries shake hands to distribute their yearly earnings among all the citizens of both the country, how will they go about?
Will the country will more earning give money to the country with fewer earnings?
No, they need to look at the average earnings of the citizens of the country, the country which has higher per capita income should give the money to the country with lower per capita income, so that every citizen gets the same amount of earning and achieve equilibrium, this is how the principle of heat transfer works.