← Quiz: JVM Memory and Garbage Collection: all 10 questions
Quiz: JVM Memory and Garbage Collection · Question 4 of 10
When does an object become eligible for garbage collection?
When does an object become eligible for garbage collection?
- A.When its reference count becomes zero
- B.When no chain of references from a GC root can reach it
- C.When System.gc() is called
- D.When the method that created it is called again
Answer & explanation
Correct answer: When no chain of references from a GC root can reach it
The JVM traces from roots (locals, statics, live threads). Unreachable objects are garbage, even if they reference each other.
Can you get the rest right without peeking?
Take the timed Quiz: JVM Memory and Garbage Collection quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →