The heat transferred is -30J
When the gas undergoes compression, work is done on the gas and its internal energy increases.
According to the first law of thermodynamics, the increase in internal energyΔU is the sum of the heat given to the gas ΔQ and the amount of work done on the gas ΔW
![\Delta U=\Delta Q +\Delta W](https://img.qammunity.org/2019/formulas/physics/high-school/kb3a1tmpck41cdfe4ip71bnrz8bz9aqlih.png)
The work done on the gas is 150 J due to compression and the internal energy of the gas increases by 120 J.
Therefore, the heat given to the gas is given by,
![image](https://img.qammunity.org/2019/formulas/physics/high-school/fe6jhvbh21xovak5821mxnepzc7c0n2nsl.png)
Thus, an amount of heat equal to 30 J flows out of the system.