Cacti have thick stems with lots of sharp spines. How do the spines help the cactus survive?

They allow the cactus to capture more sunlight.
They help the cactus grow taller stems.
They help the cactus produce colorful flowers.
They protect the cactus from being eaten by animals.