I am going to give the solution to the problem......
I used frame of reference concept.
First, look at the diagram carefully.
Description of the diagram:
A is the position of the car when the ball is thrown straight upwards. The tall man is the person who throws and the short man is his friend.
Now, think from the friends point of view!
With respect to the friend the man is at rest. So, the man is not going to have horizontal velocity while throwing. So initial velocity of the car and the man is 0.
But the final velocity is not zero. So, the ball will not have any horizontal velocity with respect to the friend. It will only have vertical velocity.
Now look at diagram 2:
Now the car have moved with acceleration 1m/s2 to the position B. The ball has gone on top and has come down on the ground.