To understand this you must know what Archimedes’ Principle is.
Archimedes’ Principle states that a body immersed in a liquid, wholly or partly, loses its weight. The loss of weight is equal to the weight of the liquid displaced by the body. Here the ship floats because the amount of water that they displace, weighs more than the ship itself. It's called the law of Buoyancy.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcROSxc6Y1LFcfV9Sby-LagkkT25WCKexCUM2jWCSvwa-YWc07gv1-Ah1XhoS6imuXEgpXMC36ZMoQLQN59R_FKMTeWU6gCoSTF7hSb_K1zBfFQbw3UXAsmUHz6i89o5gCPuFW7-fO-ZU/s320/buoyancy.gif)