how exactly garbage collection take place?
Answers were Sorted based on User's Feedback
Answer / niraj talukdar
Garbage Collection is an automated process in Java unlike C
and C++. It executes to wipe out those objects which no
longer are used in a program or stay idle for a very long
time. This to free memory space alloted to these
objects.However, it is not guaranteed that all the idle
objects wil be destroyed every time garbage collection
process gets executed.A user can also manually call the
garbage collection to take place by executing System.gc()
method.
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / vijayakumar chinnasamy
Variable/object
1. is eligible for garbage collection when no object refers
to it.
2. Is eligible when its reference is set to null i.e
objName=null.
3. referred by method variables or local variables are
eligible for garbage collection when they go out of scope.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / vinay
Another way to call garbage collector :-
Runtime rt = Runtime.getRuntime();
rt.gc();
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / devil
As in Java its happen automatically, but if you want to do
this force fully you can do this by the use of
keyword "finalize".
| Is This Answer Correct ? | 0 Yes | 5 No |
Can we have a abstract class withought any method? What is a purspose of this?
What does flag mean in java?
What is return null in java?
How do we make a class serialize?
What is the requirement of thread in java?
Can java object be locked down for exclusive use by a given thread?
What is scope & storage allocation of global and extern variables? Explain with an example
class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?
Without creating a new object, How you can retrieve a String or other object?
What are wrapped classes in java programming?
What is the byte order of byte buffer?
what is stringtolennizer with example?