As we know that from first law of thermodynamics we have

here we know that
Q = heat given to the system
W = work done by the system
= change in internal energy of the system
now we will have
Q = 1000 J

Work done by the piston = 500 J
so work done by system of gas = -(work done by piston)

now from above equation we have


now we know that



So final internal energy of the gas is 3500 J while initial internal energy is given as 2000 J