posted 14 years ago
Actually, it's 3.
The go method will create two new objects, which will refer to each other. Then, it will let the argument refer to the one, and the method will return the other.
The main method creates a new object, which is passed to the go method. So this object will now refer to one of the two new objects in the go method, and t2 will now refer to the other object returned from the method.
Then, the method goes out of scope, so all objects become eligible for collection (note that t hides the instance member t).
If the question means that by line 7 the method hasn't gone out of scope yet, then no object is eligible, since t still has a reference to one of them, which has a reference to t2 in go, which has a reference to t1 in go.