posted 16 years ago
Notice what happens after each line executes.
X3 x2 = new X3();
x2 -> O1, an object
13. X3 x3 = new X3();
x3 -> O2, an object
14. X3 x5 = x3;
x2 -> O1, x3,x5 -> O2
15. x3 = x2;
x2,x3 -> O1, x5 -> O2
16. X3 x4 = x3;
x2,x3,x4 -> O1, x5 -> O2
17. x2 = null;
x3,x4 -> O1, x5 -> O2
Now if we look at the options.
A. x3 = null, x4 still points to O1 and x5 still points to O2
B. x4 = null, x3 still points to O1 and x5 still points to O2
C. x5 = null, x3 and x4 point to O1, but O2 is eligible for collection
D. X3 = x4, x3 and x4 still point to O1, and x5 still points to O2
E. x5 = x4, x3,x4, and x5 point to O1, but O2 is eligible for collection