Explain the term - Garbage Collection
Java performs garbage collection and eliminates the need to free objects explicitly. When an object has no references to it anywhere except in other objects that are also unreferenced, its space can be reclaimed.
Before an object is destroyed, it might be essential for the object to perform some action. For illustration:
to close an opened file. In such a case, define a finalize() method with actions to be performed before object is destroyed.