Answer:
The hollow space of the ship is filled by air. Hence it reduces the average density of the ship to lower than that of water. Therefore, since the density of the ship is less than that of water, it floats in the water. However, a piece of iron sinks because it doesn't has air filled inside it.
2nd Explanation-
The density of iron is more than the density of water therefore the weight of the nail is more than the upthrust experienced by it causing it to sink. However a ship although much larger than the nail floats because the ship is hollow from inside and this space is filled with air which reduces the average density of the ship lower than that of water. Thus even with a small portion of the ship submerged under water, the weight of the water displaced by it becomes equal to the weight of the entire ship.
Explanation:
Hope this helps you. Have a nice day ^_^