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 / surinder mehra

Garbage Collection for an object occurs in following cases:

1) All references of that object explicitly set to null
e.g. object = null
2) Object is created inside a block and reference goes out
scope once control exit that block.
3) Parent object set to null, if an object holds reference
of another object and when you set container object's
reference null, child or contained object automatically
becomes eligible for garbage collection.

Garbage Collectors are implicitly invoked by JVMs when
needed(when there is no enough space for coming objects to
store). or jvm can call garbage collectors whenever it
finds that object is not being used for long time. It is
marked as garbage and later on collected

Is This Answer Correct ?    0 Yes 0 No

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

Answer / sudeep baranwal

Garbage collection is reclaiming the unused memory by the invalid objects.Garbage collection is thread when its work unused memory Created objects from the memory.Garbage collection for responsible this process.

Is This Answer Correct ?    0 Yes 0 No

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

Answer / rana.ankur

Garbage collection is a method of jvm.In JAVA when object
iis not use in otherway there is no refrence to that object
it is ellegible for Garbage collection.

demon thread is used and its is known as Garbage
collectior..
and finalize method are also invoke to give last chance to
object to save it imprtant data..thanking you

Is This Answer Correct ?    0 Yes 0 No

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

Answer / birhane mehari

yes

Is This Answer Correct ?    0 Yes 0 No

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

Answer / 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

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

Answer / tulsi

Garbage collection means deallocation of variables,which
are of no use(variables that wont be usefull in future).It
is a automatic process that occurs during the execution of
your program. In other lanuages this facility is not
provided, we have to do it mannually where as java provides
this process known as garbage collection.

Is This Answer Correct ?    4 Yes 5 No

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

Answer / sandeep chaudhary

garbage collection is just a thread that is used for
deallocation of object.object in java are allocated in
heap area(memory ) ,particular object is not used for long
period then automatically garbage coolection calls this
object for destroyed.........

Is This Answer Correct ?    4 Yes 5 No

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

Answer / sachin deshmukh

In java doesn't allow memory leakage,Garbage collector
automatically deallocates memory.It deallocates memory of
objects that no longer has any references i.e. references
count is zero.

Is This Answer Correct ?    4 Yes 5 No

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

Answer / nitin kumar

Garbage collection is a system level thread that tracks each
memory allocation. During the idle cycles in the JVM, the
garbage collection thread check for and frees memory that
can be freed. It happen automatically during the lifetime of
a Java Technology program.

Is This Answer Correct ?    0 Yes 1 No

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

Answer / samji

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 ?    4 Yes 6 No

Post New Answer

More Core Java Interview Questions

Convert a BST into a DLL and DLL to BST in place.

0 Answers   Amazon,


What are keywords in java?

0 Answers  


how to make hashmap object as synchronized object?

2 Answers   BOB Technologies,


How to reduce flicking in animation?

3 Answers   TCS,


What is array command?

0 Answers  






How many types of equations are there?

0 Answers  


how to print a numbers from 1 to 100 with out using control structures?

4 Answers   IBM,


What are different types of states exist for a thread?

0 Answers  


Can java program run without jre?

0 Answers  


Write a program in java to calculate the difference between the sum of the odd level and even level nodes of a binary tree.

0 Answers  


What are the steps to do connection pooling in weblogic?

1 Answers   TCS,


what is meant by Garbage collection?

0 Answers   Cap Gemini,


Categories