Java
Programming and Technical
Programming
Program
void start() {
A a = new A();
B b = new B();
a.s(b);
b = null; /* Line 5 */
a = null; /* Line 6 */
System.out.println("start completed"); /* Line 7 */
}
When is the B object, created in line 3, eligible for garbage collection?
A. after line 5
B. after line 6
C. after line 7
D. There is no way to be absolutely certain.
Read Solution (Total 3)
-
- A. after line 5
- 9 years agoHelpfull: Yes(1) No(2)
- D.There is no way to be absolutely certain
- 7 years agoHelpfull: Yes(1) No(0)
- It is not possible to tell exactly when an object becomes eligible for garbage collection in Java because the garbage collector runs on its own schedule and there is no way to predict when it will run.
- 1 year agoHelpfull: Yes(0) No(0)
Java Other Question