title: Unclear about dynamic binding
body: <p>I am not understanding the concept of dynamic binding and overriding properly:</p>
  
  <p>Here is some code:</p>
  
  <pre><code>class Cake {
      public void taste (Cake c) {
          System.out.println("In taste of Cake class");
      }
  }
  
  class ChocolateCake extends Cake {
      public void taste(Cake c) {
          System.out.println("In taste (Cake version) of ChocolateCake class");
      }
      public void taste(ChocolateCake cc) {
          System.out.println("In taste (ChocolateCake version) of ChocolateCake class");
      }
  }
  
  
  public static void main(String[] args)
  {
      ChocolateCake cc = new ChocolateCake();
      Cake c = new ChocolateCake();
      Cake c1 = new Cake();
      Cake c2 = new ChocolateCake();
  
      c1.taste(cc);
      c1.taste(c);
  
      c2.taste(cc);
      c2.taste(c);
  }
  </code></pre>
  
  <p>I expected:</p>
  
  <pre><code>In taste of Cake class
  In taste of Cake class
  In taste (ChocolateCake version) of ChocolateCake class" &lt;----
  In taste (Cake version) of ChocolateCake class
  </code></pre>
  
  <p>Actual:</p>
  
  <pre><code>In taste of Cake class
  In taste of Cake class
  In taste (Cake version) of ChocolateCake class &lt;----
  In taste (Cake version) of ChocolateCake class
  </code></pre>
  
  <p>If the object is of type ChocolateCake and I call cc which is also ChocolateCake, how come the compiler shows it's getting Cake as a parameter?</p>