According to energy conservation;-  
Energy Of any body is always conserve, it can be transfer one form to another form.
Total initial energy of body = Total final energy of body
K.E(initial) = 1/2.m(v₁)²
K.E(final)   = 1/2m(v₂)²
          v₁ = 4 m/s , v₂ = 0 (in the rest)
K.E(initial)= K.E(final) +Work-done(W)

Work-done(W) = K.E(initial) - K.E(final)
                  W = 1/2(35+5)4²
                  W = 40*8 =320 j.
Note; - Here work is done by the trolley to resist the friction.
            It means work-done by trolley = -( work-done by friction)  

calculation is wrong. it should be 320J(=40*8)
yeah, its wrong ,thanks