Hi,
Actually all the objects will be on a heap. Object references are not objects at all. So neither of c1, c2, c3 and cb will be on the heap. They all will be on the stack only.
Now, c1 will be pointing to a new object object1 of type Cardboard and c2 will be pointing to a new object object2 of type Cardboard. Remember that these are only references. So when we pass c2 as an argument, we are actually assigning a new reference to the already available object (pointed to by c2). So cb also now points to object2. Within the function, this object reference cb is set to null and the null object is returned. This is assigned to c3.
Note that the connection of cb with object2 has been cut, but still object2 has a reference c2 pointing to it.
Now c1 is set to null. So, object1 is eligible now for garbage collection. Totally, the references c1, cb and c3 point to no objects. Object1 has no reference now. Object2 has c2 pointing to it.
So, only one object is eligible for garbage collection.
Get back in case of any more doubts...
