title: Which objects are eligible for GC?
body: <pre><code>class CardBoard {
    Short story = 200;
    CardBoard go(CardBoard cb) {
      cb = null;
      return cb;
    }
    public static void main(String[] args) {
      CardBoard c1 = new CardBoard();
      CardBoard c2 = new CardBoard();
      CardBoard c3 = c1.go(c2);
       System.out.println("c3 value : "+c3);
       c1 = null;
       System.out.println("c1 value : "+c1);
       System.out.println("c2 value : "+c2);
      // do Stuff
    } 
  }
  </code></pre>
  
  <p>This is an example from the SCJP6 mock exam. The question states: When // doStuff is reached, how many objects are eligible for GC? And the answer is (2 objects) because:             Only one CardBoard object (c1) is eligible, but it has an associated Short
  wrapper object that is also eligible.</p>
  
  <p>When I execute the code, it looks like c3 also points to null... so I would have said that 3 objects are eligible for GC.</p>
  
  <p>Can someone please guide me through the logic of this code.</p>