Solution:
Concept: A body is at rest if it does not change its position with respect to a fixed point in its surroundings. It is in motion if it keeps changing its position with time with respect to that point. Rest and motion are relative. A body can be at rest with respect to one object and in motion with respect to another object at the same time, so we must always say what it is compared with.
Step 1 — Part (a): walking in a stationary train.
The person changes his position inside the compartment, so he is in motion relative to the compartment. The train is not moving, so changing his place in the compartment also changes his position with respect to the platform. He is in motion relative to the platform too.
Step 2 — Part (b): sitting in a moving train.
The two persons sitting side by side move together with the train, so their positions relative to each other do not change. He is at rest relative to the person beside him. Both keep changing their position with respect to the platform, so he is in motion relative to the platform.
Watch out: In (a) the train is stationary, so the compartment and the platform do not move with respect to each other; a body moving relative to one is moving relative to the other.
Therefore, (a) the person is in motion relative to the compartment and in motion relative to the platform; (b) the person is at rest relative to the person by his side and in motion relative to the platform.