From the following code how many objects are eligible for garbage collection? String string1 = "Test"; String string2 = "Today"; string1 = null; string1 = string2;
A) 1 B) 2 C) 3 D) 0
I answered 0 but the correct answer is one. I answered 0, bcos string1 is set to null, but in the very next line, is says string1 = string2.
plz explain.
SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
posted
0
Jayashree, please quote the exact source of these questions. This one is clearly wrong.