Capgemini Interview Question

Explain the role of garbage collector in Java. What is finalize() method in it?

Interview Answer

Anonymous

Jun 28, 2018

By using finalization, you can define specific actions that will occur when an object is just about to be reclaimed by the garbage collector. To add a finalizer to a class, you simply define the finalize() method. The java run time calls that method whenever it is about to recycle an object of that class.