How is Garbage collection done in Java?

Answers were Sorted based on User's Feedback



How is Garbage collection done in Java?..

Answer / sandeep

Garbage Collection is a complex feature in Java Technology.
By Programme we cannot cause gc but we can request JVM using
gc() method but it does not gurantee. Actually when an
object in our programme become unreachable it is ready to
garbage collection..the garbage collection runs periodically
and then claim the memory it does occupy ( the unreachable
object)..and is how garbage collected is done.

Is This Answer Correct ?    17 Yes 2 No

How is Garbage collection done in Java?..

Answer / boomiraj

Programmer can not cause the garbage collector.
We can call the garbage collection using System.gc();
And we can set the variable value equal to null, it assign that variable garbage rest the that use.

Is This Answer Correct ?    3 Yes 1 No

How is Garbage collection done in Java?..

Answer / 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

More Core Java Interview Questions

What is the blank final variable?

3 Answers  


Can we sort hashmap in java?

0 Answers  


Why does java not support operator overloading?

0 Answers  


What is a parameter in java?

0 Answers  


Which collection is sorted in java?

0 Answers  






What are the Static and Dynamic Variables? Differentiate them.

0 Answers   CGI,


Explain about field hiding in java?

0 Answers  


Describe method overriding

0 Answers  


What does three dots mean in java?

0 Answers  


What is the difference between the boolean & operator and the && operator in java programming?

0 Answers  


Does java support multiple inheritances?

0 Answers  


why there are multiple catches for a try block.don't tell me that there can be multiple exception of a code segment that's why.tell me the real fact behind this.

4 Answers  


Categories