What is garbage collection in Java, and how can it be used ?
Answer Posted / rahulmishra642
1>Garbage collection is a deamon thread which runs at the background to support the nin deamon thread.
2>garbage collector is responsible to destroy the useless objects.
3>An obejct is eligible for GC if and only if it doesn;t have any reference.
4>we can also call GC explicitly by System Class and Runtime class
By System Class:
- System.gc();
By Runtime Class
-Runtime r = Runtime.getRuntime(); (here we are creating runtime object by using factory method)
now, you can call gc() method
-r.gc();
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain the different forms of polymorphism?
How many threads can I run java?
What is functional interface in java?
What is the difference between comparison done by equals method and == operator?
Why do we need data structure in java?
How many types of classes are there in java?
What is the purpose of checked and unchecked exceptions in JAVA?
Is set ordered in java?
Why we use methods in java?
Explain about member inner classes?
How do you sort a set in java?
How do you clear a list in java?
What is the purpose of skeleton and stub?
Explain about the security aspect of java?
What is the purpose of a volatile variable?