I'm doing the practice exam at the Sun Learning center. Here is one of the questions.
When is the object created at line 3 eligible for garbage colection?
a. It is eligible after line 7
b. It is eligible after line 8
c. It is eligible after line 9
d. It is not eligible for garbage collection in this method.
1. public class TipTop {
2. public
String tipper() {
3. Object tip = new Object();
4. String[] top = new String[2];
5. top[0] = "this";
6. top[1] = "that";
7. tip = top[1];
8. top[1] = top[0];
9. tip = null;
10. return top[0];
11. }
12. }
The answer I entered is C. But the site says that the correct answer is A because there are no valid references left to the object. Am i missing something. Or is it because tip now refers to a different object in line 8.