So, in my physics textbook it's written that the kinetic energy possessed by a body is equal to the amount of work done by an opposing force to stop the body, now that got me thinking that when a ball hits a wall, the wall which is the opposing force does no work because there is no displacement, so to say isn't the kinetic energy possessed by the ball zero?
[Physics] What work is done by the wall when a ball hits it
collisionnewtonian-mechanicspotential energywork
Related Solutions
The assumption in these problems is that the collision takes place instantaneously so that gravity has no time to change the momentum of the ball during the collision.
To see why this is makes sense, let $y$ denote the vertical direction, and notice that if the collision took some small amount of time $\delta t>0$ then the change in vertical momentum of the ball would be (by integrating both sides of Newton's second law) $$ \delta p_y = \int_{t_0}^{t_0+\delta t}dt \,F(t) = F(t_0)\delta t + \mathcal O(\delta t^2) $$ so we see that as the collision time goes to zero, so does the change in momentum in the vertical direction.
The first thing you must do is define your system.
If the system is the book alone the the external forces on the book are the force that you exert on the book and the gravitational attraction on the book by the Earth.
If the book starts and finishes at rest then there is no change in the kinetic energy.
The work done by you on the book is positive as the direction of the force that you exert on the book is the same as the displacement of the book.
The work done by the gravitational force due to the Earth is negative because the gravitational force is in the opposite direction to the displacement of the book.
If the two external forces are equal in magnitude and opposite in direction then the net work done on the book is zero (equal to the change in kinetic energy).
Of course one could reason that the net external force on the book is zero so the net work done by external forces on the book is zero.
There is no mention of gravitational potential energy because it is the energy associated with the book and the Earth as a system.
So now let's consider this system of the book and the Earth.
The external force is now the force that you apply on the book.
The force that the Earth exerts on the book is an internal force and its Newton third law pair is the force that the book exerts on the Earth.
When you do positive work separating the book and the Earth that work increases the gravitational potential energy of the book-Earth system.
If you released the book the separation between the book and the Earth will decrease and the gravitational potential energy of the system will decrease.
The book (and the Earth) would then have kinetic energy.
Usually only the motion and kinetic energy of the book is considered because the mass of the Earth is so much greater than the book.
This results in the speed and kinetic energy of the Earth being very much smaller that that of the book.
Best Answer
The comment, force by the wall that does not deform (the ideal, usual case assumed in the question) does no work, made by @JánLalinský has helped me rewrite my answer.
I will consider what happens when the wall does not move and thus the wall does no work on a ball.
The effect a golf ball moving at $150\, \rm mph\,(240 \rm kph)$ hitting a “fixed” wall can be seen in this video shot at $70,000$ frames per second.
From this video I have extracted the following stills.
The ball hits the wall with the wall exerting an external force on the left-hand side of the ball which is in contact with the wall.
What you can infer from the stills is that the left-hand side of the ball hits the wall and slows down to a stop very rapidly whilst the inside of the ball is still moving to the right.
As time progresses the ball is compressed with its internal parts slowing down in the process and some of the ball's kinetic energy is converted into elastic potential energy within the ball in the same way as when a spring is compressed.
Eventually the centre of mass of the ball must stop moving relative to the wall and at that stage the ball's initially kinetic energy has been converted into elastic potential energy, oscillatory kinetic energy of the ball and has done work permanently deforming the ball - breaking bonds.
That oscillatory motion of the internal parts of the ball is due to compression pulse(s) moving within the ball and this effect is the basis of some experiments used to measure the speed of sound in a rod as described here. There is also heat generated some of which is due to the damping of the oscillatory motion of the internal parts of the ball.
Thus a ball can stopped the ball by exerting an external force on it due to a wall with the wall assumed not to deform and thus doing no work.
It is the internal forces within the ball which are the forces doing the work.
The process is then reversed with the elastic potential energy being converted into the kinetic energy of the ball as its centre of mass moves to the right but the collision is not elastic as some of the ball's initial kinetic energy has been converted into heat, (sound), and used to permanently deform the ball - break bonds.