← Quiz: JVM Memory and Garbage Collection: all 10 questions
Quiz: JVM Memory and Garbage Collection · Question 5 of 10
Two objects reference only each other, and no variable points to either. What happens?
Two objects reference only each other, and no variable points to either. What happens?
- A.They are never collected, causing a leak
- B.The program throws an error
- C.Both are eligible for garbage collection
- D.Only one of them is collected
Answer & explanation
Correct answer: Both are eligible for garbage collection
Reachability is checked from GC roots, so a cycle with no path from a root is collected.
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 →