Head-on Elastic Collision
Let two balls A and B having masses mA and mB respectively collide head-on. Let vAi and vBi be the velocities of the two balls before collision and vAf and vBf be their velocities after the collision.
Now applying the laws of conservation of momentum and kinetic energy,
For conservation of momentum
mAvAi + mAvBi = mAvAf + mBvBf
For conservation of kinetic energy
½mAvAi2 + ½mBvBi2 = ½mAvAf2 + ½mBvBf2
There are only two unknown quantities (velocities of the balls after collision) and there are two independent equations.

Case I: Collision of two particles of identical masses
Suppose that the two balls colliding with each other are identical i.e. mA = mB = m.
Then, the second term in the equations will drop out resulting in
vAf = vBi
vBf = vAi
If two identical balls collide head-on, their velocities after collision get interchanged. After collision, the velocity of A is same as that of B before collision and the velocity of B is same as that of A before collision.
Case II: Collision of two particles of unequal masses
Assume that mB is very large compared to mA and particle B is initially at rest.
mB >> mA and vBi = 0
Then, the mass mA can be neglected in comparison to mB.
vAf ≈ –vAi
vBf ≈ 0
After collision, the heavy particle continues to be at rest. The light particle returns back on its path with a velocity equal to its the initial velocity. This is what happens when a child hits a wall with a ball.