Q1) Which part of the memory is involved in Garbage Collection? Stack or Heap? Ans) Heap | |||
Q2)What is responsiblity of Garbage Collector? Ans) Garbage collector frees the memory occupied by the unreachable objects during the java program by deleting these unreachable objects. It ensures that the available memory will be used efficiently, but does not guarantee that there will be sufficient memory for the program to run. | |||
Q3) Is garbage collector a dameon thread? Ans) Yes GC is a dameon thread. A dameon thread runs behind the application. It is started by JVM. The thread stops when all non-dameon threads stop. | |||
Q4)Garbage Collector is controlled by whom? Ans) The JVM controls the Garbage Collector; it decides when to run the Garbage Collector. JVM runs the Garbage Collector when it realizes that the memory is running low, but this behavior of jvm can not be guaranteed. One can request the Garbage Collection to happen from within the java program but there is no guarantee that this request will be taken care of by jvm. | |||
Q5) When does an object become eligible for garbage collection? Ans) An object becomes eligible for Garbage Collection when no live thread can access it.
|
Java Garbage Collection Interview Questions
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Please Provide your feedback here