According to the first law of thermodynamics, the change in internal energy \( \Delta U \) is given by the formula:
\[
\Delta U = Q - W
\]
Where:
- \( Q = 100 \, \text{J} \) is the heat absorbed by the gas,
- \( W = 40 \, \text{J} \) is the work done by the gas on its surroundings.
Substituting the known values:
\[
\Delta U = 100 - 40 = 60 \, \text{J}
\]
Thus, the change in internal energy of the gas is \( 60 \, \text{J} \).