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
Is it possible to compare various strings with the help of == operator? What are the risks involved?
What is the definition of tree ?
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?
What is the significance of java packages?
How we create object in copy constructor?
What is the difference between class forname and new?
Is age discrete or continuous?
Explain the inheritance?
How many bytes is 255 characters?
What are the uses of synchronized keyword?
Can we assign null to double in java?
What does system.gc() and runtime.gc() methods do?
Is java an open source?
How is a structure different from array ?
What is the difference amongst jvm spec, jvm implementation, jvm runtime ?