title: Static Vs. Dynamic Binding in Java
body: <p>I'm currently doing an assignment for one of my classes, and in it, I have to give examples, using Java syntax, of <em>static</em> and <em>dynamic binding</em>.</p>
  
  <p>I understand the basic concept, that static binding happens at compile time and dynamic binding happens at runtime, but I can't figure out how they actually work specifically.</p>
  
  <p>I found an example of static binding online that gives this example:</p>
  
  <pre><code>public static void callEat(Animal animal) {
      System.out.println("Animal is eating");
  }
  
  public static void callEat(Dog dog) {
      System.out.println("Dog is eating");
  }
  
  public static void main(String args[])
  {
      Animal a = new Dog();
      callEat(a);
  }
  </code></pre>
  
  <p>And that this would print "animal is eating" because <em>the call to <code>callEat</code> uses static binding</em>, but I'm unsure as to <em>why</em> this is considered static binding.</p>
  
  <p>So far none of the sources I've seen have managed to explain this in a way that I can follow.</p>