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 java ide should I use?

775


why Interface used?

760


What is super?

803


Explain the difference between comparator and comparable in java?

708


What is hash in java?

729


What is connection class in java?

756


How do I stop concurrentmodificationexception?

757


How do generics work in java?

717


What is a numeric format?

794


What are jee technologies?

793


How do you write a scanner class in java?

793


What lambda means?

771


What type of language is java?

772


What is the difference between form & report?

835


What are the restrictions imposed by a Security Manager on Applets?.

2344