Given:
class Main { /*from w ww . jav a 2 s . c o m*/ Short story = 200; Main go(Main cb) { cb = null; return cb; } public static void main(String[] args) { Main c1 = new Main(); Main c2 = new Main(); Main c3 = c1.go(c2); c1 = null; // do Stuff } }
When // do Stuff is reached, how many objects are eligible for garbage collection?
C is correct.
Only one Main object (c1) is eligible, but it has an associated Short wrapper object that is also eligible.