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

Explain why wait(), notify() and notifyall() methods are in object class rather than in thread class?

576


Can java inner class be static?

576


What are the Main functions of Java?

639


Does java list allow null?

554


What are selection structures?

550






What is blank final variable?

582


What is regex java?

575


Explain the difference between a Thread and a Process.

578


Explain the importance of finally over return statement?

620


What are different types of expressions?

562


What is a pointer and does java support pointers?

569


How is final different from finally and finalize?

504


What do you understand by classes in java?

576


Can we create an object of static class in java?

610


Can this keyword be used to refer static members?

557