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
String and stringbuffer both represent string objects. Can we compare string and stringbuffer in java?
How would you format a date in java? I.e. In the ddmmyyy format?
what is the use of bean managed and container managed with example?
What is a top level class in java?
Why do we need data structure in java?
What is java util?
Can a class be a super class and a sub-class at the same time? Give example.
What happens when a thrown exception is not handled?
worst case complexities of Quick sort and Merge sort.
What is array length?
What is thread safe singleton?
What are the characteristics of Final,Finally and Finalize keywords.
Can we use different return types for methods when overridden?
Does sprintf allocate memory?
Describe what a thread-local variable is in java?