When can an object be garbage collected?
QuizMediumJava onlyAsked in: Accenture, TCS
Which make an object eligible for garbage collection? Pick all that apply.
- The only variable pointing at it is set to null
- The only variable pointing at it is assigned another object
- Two objects point only at each other, and nothing else points at either
- Calling
System.gc()while a static field still points at it
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.