When the train is stopped suddenly, then it comes in the state of rest but the balls remain in the state of motion. So, due to inertia of motion, the balls move in the forward direction.As the balls are of same size but of different materials that means their mass will be different. So, both the balls will move with different speeds
They will not move with same speed because mass of balls are different and mass is directly proportion to inertia and iron ball has greater mass than rubber so inertia is also greater . iron ball speed is lesser than rubber