Explain garbage collection?

By: Karthik Printer Friendly Format    

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.



Most Viewed Articles (in Interview )

What types of comments are available in the JSP?

Interview Question: What is Action Class?

Interview Question: Is there a particularly good IDE to use with Struts ?

Interview Question: Do ActionForms have to be true JavaBeans?

Interview Question: What is local interface. How values will be passed?

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

Question: How would you go about analyzing performance of an application?

What is similarities/difference between an Abstract class and Interface?

What are implicit Objects available to the JSP Page?

Interview Question: What is Struts?

Interview Question: How is the MVC design pattern used in Struts framework?

Interview Question: Who makes the Struts?

Interview Question: Why it is called Struts?

Interview Question: Write code of any Action Class?

Interview Question: What is Struts Validator Framework?

Latest Articles (in Interview)

Comment on this tutorial