Once an object is garbage collected, It can no longer become reachable again.
Click Here to See Answer .....
Subscribe to my RSS feed and get more JAVA Question, and Guideline, Plus a lot more great advice to help your Software Career.
advanced JAVA interview questions, j2ee interview questions, java tutorial, Core Java Job Interview Questions, JAVA, JSP, SERVLETS, EJB, STRUTS, XML, ANT, LOG4J, WEBLOGIC, Interview questions for different java technologies like Core Java, JSP, servlets, EJB, JMS< JNDI, JMS
Once an object is garbage collected, It can no longer become reachable again.
The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup, before the object gets garbage collected. For example, closing an opened database Connection.
Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.
An object’s finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an object’s finalize() method may be invoked by other objects.
It is a daemon thread.
Or How you can force the garbage collection? Or What is the purpose of garbage collection in Java, and when is it used? Or What is Garbage Collection and how to call it explicitly? Or Explain Garbage collection mechanism in Java? Garbage collection is one of the most important features of Java. The purpose 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. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. 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. In 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. Garbage collection is an automatic process and can't be forced. There is no guarantee that Garbage collection will start immediately upon request of System.gc().
Java Interview Questions site discussing core java IT technical interview questions in detail. These are some of the java job interview questions me and my friends have faced regularly in campus interviews and off campuses. I have consolidated all of them from different people and communities into a vast resource of core java interview questions all in one place. So I am giving you a chance to prepare well by going through each of the java interview faqs organized by java topics, before attending a technical interview on java.