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


Please Help Members By Posting Answers For Below Questions

String and stringbuffer both represent string objects. Can we compare string and stringbuffer in java?

556


How would you format a date in java? I.e. In the ddmmyyy format?

778


what is the use of bean managed and container managed with example?

1499


What is a top level class in java?

537


Why do we need data structure in java?

575






What is java util?

541


Can a class be a super class and a sub-class at the same time? Give example.

800


What happens when a thrown exception is not handled?

582


worst case complexities of Quick sort and Merge sort.

606


What is array length?

507


What is thread safe singleton?

517


What are the characteristics of Final,Finally and Finalize keywords.

705


Can we use different return types for methods when overridden?

556


Does sprintf allocate memory?

595


Describe what a thread-local variable is in java?

571