Hi guys, a Self
Test question on page 269 of Sun Certified Programmer for
Java 6 says
class CardBoard {
Short story = 200;
CardBoard go (CardBoard cb) {
cb = null;
return cb;
}
public static void main(
String[] args) {
// TODO Auto-generated method stub
CardBoard c1 = new CardBoard();
CardBoard c2 = new CardBoard();
CardBoard c3 = c1.go(c2);
c1 = null;
if (c3 == null)
System.out.println("c3 is null");
}
}
The question is, "How many objects are eligible for garbage collection and the answer given, is 2 - c1 and c1.story. How come c3 isn't eligible?