title: Java method overloading + double dispatch
body: <p>Can anybody explain in detail the reason the overloaded method <code>print(Parent parent)</code> is invoked when working with <code>Child</code> instance in my test piece of code?</p>
  
  <p>Any pecularities of virtual methods or methods overloading/resolution in Java involved here?
  Any direct reference to Java Lang Spec?
  Which term describes this behaviour?
  Thanks a lot.</p>
  
  <pre><code>public class InheritancePlay {
  
      public static class Parent {        
          public void doJob(Worker worker) {
              System.out.println("this is " + this.getClass().getName());
  
              worker.print(this);
          }
      }
  
      public static class Child extends Parent {
      }
  
      public static class Worker {
          public void print(Parent parent) {
              System.out.println("Why this method resolution happens?");
          }
  
          public void print(Child child) {
              System.out.println("This is not called");
          }
      }
  
      public static void main(String[] args) {
          Child child = new Child();
          Worker worker = new Worker();
  
          child.doJob(worker);
      }
  }
  </code></pre>