now the question is :- How many objects are eligible for Garbage Collection after line //do stuff ?
According to me all the c1,c2 and c3 are eligible for garbage collection . However the answer says only two objects are eligible for garbage collection ie c1 and associated Short object .
the reference variable c3 doesn't refer any object since the new key word is not used to instanciate the object.
c2 object is not eligible the GC because the cb object can't make it refer to a different object or null
c1 object is changed to null, and since it holds a short object, it'll too set up to null and these are the objects eligible the GC