How is Garbage collection done in Java?

Answer Posted / harish

Garbage Collection is carried out based on the reference
type an object is currently in.
There are 4 types of references in java
1)strong reference
2)soft reference
3)weak reference
4)phantom reference

the last one is the weakest of the weak.
JVM will try get all those of object that are fell in this
category and try to collect it.
But it is not neccessary the object in phantom reference
phase will always be garbage collected.

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is string substring?

805


What is static import?

853


What is wrapper class html?

716


Define an abstract class with reference to java.

782


What is int lol?

864


Can we overload the methods by making them static?

744


Explain the differences between abstraction and encapsulation?

786


Can a main method be overloaded?

781


What is the use of parse function in java?

719


What is Major and importance difference between for and foreach loop ?

822


When is the finalize() called? What is the purpose of finalization?

832


What type of language is java?

765


Can we override the static method?

773


What is the difference between int and integer in java?

780


Can we serialize arraylist in java?

776