What is garbage collection in Java, and how can it be used ?

Answers were Sorted based on User's Feedback



What is garbage collection in Java, and how can it be used ?..

Answer / pranab dutta

When a Java object becomes unreachable to the program, then
it is subjected to garbage collection. The main use of
garbage collection is to identify and discard objects that
are no longer needed by a program so that their resources
can be reclaimed and reused.

Is This Answer Correct ?    322 Yes 35 No

What is garbage collection in Java, and how can it be used ?..

Answer / janet

When an object is no longer referred to by any
variable,java automatically reclaims memory used by that
object.This is known as garbage collection.
System.gc() method may be used to call it explicitly.

Is This Answer Correct ?    180 Yes 34 No

What is garbage collection in Java, and how can it be used ?..

Answer / devarathnam c,kotagudibanda(po

Hi...
GarbageCollector: Whenever an object is no longer used in
the program at that time the garbage collector reclaims the
memory of an object.It is controlled by the JVM ,The JVM
runs periadically by using "mark" and "sweep"algorithms.
Instead of "destructor" in c++ , java supports garbage
collector.

Is This Answer Correct ?    84 Yes 21 No

What is garbage collection in Java, and how can it be used ?..

Answer / ms

garbage collecton in java means, if a particular object in
a program is not being refered since long time then it will
be automatically deleted with the help of garbage collector
so that some amount of memory is saved.we can explicitily
call it by adding a method system.gc()in the program.so in
this case there is no need to use'destructor'to destroy the
objects.

Is This Answer Correct ?    69 Yes 17 No

What is garbage collection in Java, and how can it be used ?..

Answer / veer

When an object has of no use in a program then it has to be
discarded to free the occupied space by it so that other
object can fill the space.That is what Garbaghe collection
is.

Is This Answer Correct ?    42 Yes 12 No

What is garbage collection in Java, and how can it be used ?..

Answer / sivadasan

Garbage collection is a thread, that runs to reclaim the
memory by destroying objects which object is cannot be
referenced anymore.

Deleting Dynamically created objects from the memory.

Finalize method used to achieve garbage collection.

By using Runtime.gc() or System.gc() the object will be
garbage collected.

Is This Answer Correct ?    30 Yes 14 No

What is garbage collection in Java, and how can it be used ?..

Answer / syed sikandar bakht

when an object in memory is no longer refered by a variable,
the garbage collector automatically move it to garbage
collection.
instead of calling destructor JVM do it automatically, as we
use destructor in c++ to destroy the object.

Is This Answer Correct ?    20 Yes 6 No

What is garbage collection in Java, and how can it be used ?..

Answer / sangeetha

when we remove the object that it will be stored particular
memory space these are known as garbage collection.

It is finalize method is used in the garbage collection.

Is This Answer Correct ?    32 Yes 20 No

What is garbage collection in Java, and how can it be used ?..

Answer / ravi

when there are no refrences to an object,means that it is
not in use anymore.so the JVM marks it for garbage
collection ,which is basically a process of taking back the
resources from the object which was given to it earlier.

Is This Answer Correct ?    14 Yes 2 No

What is garbage collection in Java, and how can it be used ?..

Answer / dsr

when ever object scope is over at that the object memory
removed.This is nown as garbageCollection.

Is This Answer Correct ?    19 Yes 11 No

Post New Answer

More Core Java Interview Questions

What is multiple inheritance? Is it supported by java?

0 Answers  


Explain the usage of this with constructors?

0 Answers  


Which variables are stored in heap?

0 Answers  


What is anti pattern in programming?

0 Answers  


How do you add an arraylist to an array in java?

0 Answers  






7) Suppose there is Student class like class student { int age; string name; } We want to store these objects in a HashMap. Do we need to override any methods in Student class? If any which ones and why? what if i just override equals or just hashcode? what will be the results in both the cases?

4 Answers   CSC, Nagarro, RBS,


Why do we use bufferedreader?

0 Answers  


Is there any difference between synchronized methods and synchronized statements?

0 Answers  


What is the best way to findout the time/memory consuming process?

0 Answers  


what is purpose of writting public static void main(Strind arg[]) in java..?

4 Answers   ITC Infotech,


What are the restriction imposed on a static method or a static block of code?

0 Answers  


What are the override methods in Object class?

2 Answers   Tech Mahindra, Wipro,


Categories