Explain the purpose of garbage collection that the JVM uses.The essential purpose of garbage collection is to reclaim the memory space that was occupied by the objects that are no longer required for the application. Garbage collection is done in java by a program called garbage collector. An object in the application is subjected to garbage collected when it is unreachable to the application.
Explain the purpose of garbage collection that the JVM uses. Garbage collection in Java identifies and discards the objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used. The finalize() method is called by garbage collector when it determines no more references to the object exists.