posted 16 years ago
Hi Enrique, first of all could you use the code tags, for your formatting, makes your code easier to interpret. Also check your spelling, on the code your return statement is spelt incorrectly, as it stands it woudn't compile in addition your reference types are incorrect, as they should be CardBoard not Cardboard and your class declaration should be spelt class not Class.
You also need to quote your source, was it a mock exam question for example, if so where from.
Ok so lets have a look, here is your example reproduced to cover the spelling changes:
Here is created 2 new Cardboard objects with the references c1 and c2. Then a new reference is created c3 which is basically assigned a null reference through c1.go(c2) for which you are making a new null reference to c2 and returning it so no new objects are created just null references. Then you set c1 to null so the new object created by c1 is all out there on the heap alone waiting for the garbage collector. So I'd say one object!
be a well encapsulated person, don't expose your privates, unless you public void getWife()!