If an item is denser than water it will sink, it is less dense it will float. Apples can float because 25% of their volume is air. Even the same applies to Pumpkins. Though they are large in size their 1/3rd volume is air and they are less dense from inside.
Look at the video and learn the logic behind why do apples float in water? You may even try the same!!