from K&B
question: When // dostuff is reached, how many, objects are elegible for GC?
a-0
b-1
c-2
d-Compilatio fails
e-it is not possible to know
f-An exception is thrown at runtime.
So i thought like this:
c1=null; so 1 object
c2 = new Cardboard();
then c2 is passed as an argument, since is an object what is passed is a reference to the object c2 representes, since on the method
the object which is passed by reference is set to null so c2 no longer poits to the object that inicialy it pointed, but instead it points to null
so: c2=null, 2º object elegible for GC
since c3 is initialized with the object return by the go ethod and it returns null
so c3 is null, 3º object elegible for GC.
Now i know that my way of thinking isn't correct i just can't understand why!