JVM and Garbage Collections Interview Questions and Answers - 1
What is Garbage Collection and how to call it explicitly?
When an object is no longer referred to by any variable, java automatically reclaims memory used by that object.
This is known as garbage collection.
system.gc() method may be used to call it explicitly.
What is the purpose of finalization?
The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.
What is finalize() method?
finalize() method is used just before an object is destroyed and can be called just prior to garbage collection.
Does garbage collection guarantee that a perform will not run out of memory?
Garbage collection does not guarantee that a program will not run out of memory. As garbage collection is JVM dependent then it is possible for programs to use memory resources faster than they are garbage collected.
Moreover garbage method will be run before an object is Garbage collected, it is called by the garbage collector on an object when garbage collection determines that there no more references to the object.
The garbage collection is controlled, it means you cannot predict when it will happen, you thus cannot predict exactly when the finalize method will run.
Once a variable is no longer referenced by anything it is available for garbage collection
When is an object subject to garbage collection?
An object is subject to garbage collection when it becomes unreachable to the program in which it is used.
7000+ TNMAWS Questions and Answers Pdf More
Tamil Nadu Municipal Administration Water Supply Question Paper Pdf More
7000+ Nuclear Metals Questions and Answers Pdf More
7000+ Fuel System Questions and Answers Pdf More
7000+ Metallurgy Solved MCQS Questions Pdf More
100+ Decimal Fraction Questions with Answers for SSC Exams More
TNPSC Physics Quiz More
7000+ Daily Gk Questions and Answers Pdf More
50+ Aptitude Banker's Discount Problems with Solutions Pdf More
General English Word Pairs for TNPSC Group 1, 2, 4, VAO Exams More