Answer with Explanation:
Let me answer this in a simple way, since the density of stone is greater than that of water, the stone sinks as the weight of the stone is greater than the weight of water displaced by it. But the ship is designed in such a way that the relative density of the ship always becomes less than that of water. Therefore, the weight of the water displaced becomes equal to the total weight of the ship and thus it floats.
There are many other ways to explain this but this should give you the general idea.