Heat and work cross the boundary

Heat is energy crossing a boundary because of a temperature difference and work is energy crossing it any other way; both depend on the path a process takes, while the energy stored inside depends only on the state.

From Thermodynamics.