title: Garbage collection mock for the OCPJP exam
body: <p>Four objects are eligible for garbage collection when <code>i3 = null;</code> is executed in the class shown below. I've added comments to explain how I got this answer. Is my reasoning correct?</p>
  
  <pre><code>public class Icelandic extends Horse{
      public void makeNoise(){
          System.out.println("vinny");
      }
  
      public static void main(String args[]){
          /**
           * 2 objects created
           */
          Icelandic i1 = new Icelandic();
  
          /**
           * 2 objects created
           */
          Icelandic i2 = new Icelandic();
  
          /**
           * 2 objects created
           */
          Icelandic i3 = new Icelandic();
  
          /**
           * i3 is now pointing at i1, original Icelandic() referred to by i3 now
               * has no reference -  2 objects now have no reference
           */
          i3 = i1;
  
          /**
           * i3 is now pointing at i1, original Icelandic() referred to by i1 now
               * has no reference -  2 objects now have no reference
           */
          i1 = i2;
  
          /**
           * Total of six objects created, 4 objects no longer have a reference so 4
               * can be garbage collected.
           * 
           * Setting to null below doesn't make any difference to garbage collector
               * as objects now do not have a reference
           */
          i2 = null;
          i3 = null;
      }
  }
  
  interface Animal {
      void makeNoise();
  }
  
  class Horse implements Animal{
      Long weight = 1200L;
  
      public void makeNoise() {
          System.out.println("whinny");
      }    
  }
  </code></pre>