Why does a piece of iron sinks but a ship made of the same iron floats?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.
If the buoyant force is greater than the gravitational force, the object will float, but if the opposite is true, the object will sink.