title: Determining how many objects are eligible for GC
body: <p>There is a question in SCJP third chapter.<br>
  See the following code:</p>
  
  <pre><code>public class Sample_1 {
  
  
      Short story = 200;
  
      Sample_1 go(Sample_1 sample){
          sample = null;
          return sample;
      }
  
      public static void main(String a[]){
          Sample_1 sample1 =new  Sample_1();
          Sample_1 sample2 =new  Sample_1();
          Sample_1 sample3 = sample1.go(sample2);
  
          sample1 = null;
  
          //DO STUFF
  
      }
  
  }
  </code></pre>
  
  <p>Question: How are many objects are eligible for GC @ line <code>//DO STUFF</code>?</p>
  
  <p>options:<br>
  0<br>
  1<br>
  2<br>
  Compilation Fails<br>
  Its not possible to know<br>
  An exception is thrown at run time  </p>
  
  <p>Book says: the correct ansert is 2. It says that "only one Sample_1 object (sample1) is eligible for GC,but it has associated Short value with it.So there are two objects eligibe for GC"</p>
  
  <p>Still not able to understand this answer. We are already nulling sample1 object. From my view there are no objects for GC.</p>
  
  <p>Any Idea?</p>