B. 24 sec
Feedback Relative speed = (45 + 30) km/hr = ( 75 x 5/18 ) m/sec = (125/6 ) m/sec .
We have to find the time taken by the slower train to pass the DRIVER of the faster train and not the complete train.
So, distance covered = Length of the slower train.
Therefore, Distance covered = 500 m.
Therefore Required time = ( 500 x 6/125 ) = 24 sec .