While internal energy refers to the total energy of all the molecules within the object, heat is the amount of energy flowing from one body to another spontaneously due to their temperature difference. Heat is a form of energy, but it is energy in transit. Heat is not a property of a system. However, the transfer of energy as heat occurs at the molecular level as a result of a temperature difference.
Consider a block of metal at high temperature, that consists of atoms that are oscillating intensely around their average positions. At low temperatures, the atoms continue to oscillate, but with less intensity. If a hotter block of metal is put in contact with a cooler block, the intensely oscillating atoms at the edge of the hotter block gives off its kinetic energy to the less oscillating atoms at the edge of the cool block. In this case there is energy transfer between these two blocks and heat flows from the hotter to the cooler block by this random vibrations.
In general, when two objects are brought into thermal contact, heat will flow between them until they come into equilibrium with each other. When a temperature difference does exist heat flows spontaneously from the warmer system to the colder system. Heat transfer occurs by conduction or by thermal radiation. When the flow of heat stops, they are said to be at the same temperature. They are then said to be in thermal equilibrium.
As with work, the amount of heat transferred depends upon the path and not simply on the initial and final conditions of the system. There are actually many ways to take the gas from state i to state f.
Also, as with work, it is important to distinguish between heat added to a system from its surroundings and heat removed from a system to its surroundings. Q is positive for heat added to the system, so if heat leaves the system, Q is negative. Because W in the equation is the work done by the system, then if work is done on the system, W will be negative and Eint will increase.
The symbol q is sometimes used to indicate the heat added to or removed from a system per unit mass. It equals the total heat (Q) added or removed divided by the mass (m).