Does garbage collection guarantee that a program will not run out of memory?
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. What is the purpose of finalization? 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. If an object is garbage collected, can it become reachable again? Once an object is garbage collected, It can no longer become reachable again. If you think that an important java interview question is missing or some answers are wrong in the site please contribute it to sriniappl@gmail.