Programming Tutorials

Explain garbage collection?

By: Karthik in Interview Tutorials on 2012-06-16  

Answer: Garbage collection is one of the most important feature of Java. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. User program cann't directly free the object from memory, instead it is the job of the garbage collector to automatically free the objects that are no longer referenced by a program. Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use. I Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected.





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Interview )

Interview Question: What is the difference between Message Driven Beans and Stateless Session beans?

Question: Explain the life-cycle methods in JSP?

What is difference between Java Bean and Enterprise Java Bean?

Name the containers which uses Border Layout as their default layout?

What are the services provided by a J2EE container?

Interview Question: What is the difference between sessioncontext and entitycontext?

Question: What is the directory structure of a web application?

Question: What is an output comment in JSP?

Interview Question: Is Struts compatible with other Java technologies?

Explain the Polymorphism principle.

What do you understand by JTA and JTS?

Getting started with Interview

Interview Question: What is the difference between find and select methods in EJB?

What are types of J2EE clients?

What is J2EE Connector architecture?

Latest Articles (in Interview)