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
What is Recursion Function?
What is a byte string?
What is covariant return type?
Is there any limitation of using inheritance?
What are the differences between heap and stack memory?
What are structs in java?
Where are variables stored?
Does the order of public and static declaration matter in main method?
Explain about OOPS concepts and fundamentals.
What is annotation in java?
What is a stack class in java ?
What is the purpose of default constructor?
Which arithmetic operations can result in the throwing of an arithmeticexception?
What is a void method java?
what is the swingutilities.invokelater(runnable) method for? : Java thread