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 )

Tell me something about J2EE component?

Interview Question: Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

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

What is the difference between interface and abstract class?

Differentiate between .ear, .jar and .war files.

Interview Question: How does Struts work?

What do you understand by a container in J2EE?

Interview Question: Do you have to credit Struts on your own website?

Interview Question: How many EJB Objects are created for a Bean?

What is JSP Scriptlet?

What are implicit Objects available to the JSP Page?

What do you understand by JSP Actions?

Why J2EE is suitable for the development of distributed multi-tiered enterprise applications?

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

Interview Question: Why are some of the class and element names counter-intuitive?

Latest Articles (in Interview)