____________ method of Java is invoked by JVM to reclaim the inaccessible memory location

Options
- reclaim()
- final()
- finalize()
- Both b and c


CORRECT ANSWER : finalize()

Discussion Board
finalize()

The java.lang.Object.finalize() is called by the garbage collector on an object when it is found out that there are no more references to the object present in the memory. A subclass of the class can override the finalize() method to dispose of system resources or to perform other cleanup.

finalize() is called before Garbage collector reclaim the Object, its last chance for any object to perform cleanup activity. In this case scenario the system resources are released that are taken by the program and the open connections are closed if any. So whenever a memory location which is inaccessible garbage collector is called to free up the memory and the resources being used by it.

Rohit Sharma 08-14-2014 07:56 PM

finalize method

finalize method is called by garbage collection thread just before collecting object, releases any system resources held like closing connection if open etc. It is called only once by GC thread.


Bunty 07-5-2013 04:28 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement