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

Is it possible to compare various strings with the help of == operator? What are the risks involved?

615


What is the definition of tree ?

585


There are two classes named classa and classb. Both classes are in the same package. Can a private member of classa can be accessed by an object of classb?

993


What is the significance of java packages?

609


How we create object in copy constructor?

638






What is the difference between class forname and new?

544


Is age discrete or continuous?

684


Explain the inheritance?

572


How many bytes is 255 characters?

548


What are the uses of synchronized keyword?

551


Can we assign null to double in java?

542


What does system.gc() and runtime.gc() methods do?

598


Is java an open source?

523


How is a structure different from array ?

579


What is the difference amongst jvm spec, jvm implementation, jvm runtime ?

503