What is the main purpose of a destructor in a class?
A) To create new objects.
B) To initialize object properties.
C) To free up resources when an object is no longer needed.
D) To define abstract methods.
Answer: C) To free up resources when an object is no longer needed.
Explanation: A destructor is a special method invoked when an object is about to be destroyed. Its main purpose is to release resources (like memory or file handles) that the object may have acquired during its lifetime. This helps in preventing memory leaks and ensuring proper resource management.