PRACTICE / UNDERSTAND / REPEAT

Java: Objects & references

Practice objects & references with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

15 questionsAnswers explainedFree · no login
Question 1 of 15
Objects & references · MCQQuestion link ↗

What happens to an object when one reference to it is set to null?

Choose one answer
Answer & explanation

Answer: It is collectible only if no relevant reachable references remain

Garbage collection is based on reachability, not one variable assignment.