The answer is given by K & B is C and E. My answer is A and B Because the two objects references X3 and X4 references the object in line 12. I am making null for those references for garbage collection. So what is wrong with my answer pls explain to me to understand the concept.
14. Given the following, 12. X3 x2 = new X3(); 13. X3 x3 = new X3(); 14. X3 x5 = x3; 15. x3 = x2; 16. X3 x4 = x3; 452 Chapter 7: Objects and Collections 17. x2 = null; 18. // insert code
What two lines of code, inserted independently at line 18, will make an object eligible for Garbage collection? (Choose two.)
A. x3 = null; B. x4 = null; C. x5 = null; D. x3 = x4; E. x5 = x4;
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