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

Can we use a switch statement with strings?

546


If try block is successfully executed, Then Is Finally block executed?

606


Explain exception chaining in java?

606


What is keyset in java?

653


What is java console application?

556






why would you use a synchronized block vs. Synchronized method? : Java thread

534


Difference between predicate, supplier and consumer ?

575


What is the argument in java?

490


Can a vector contain heterogenous objects?

592


Why is string builder not thread safe?

589


What is the significance of java packages?

609


Do we need to manually write Copy Constructor?

604


Explain the difference between the public, private, final, protected, and default modifiers?

549


Why are global variables used?

499


Which is dependent variable?

492