title: Polymorphism doesn't work in method arguments in Java
body: <p>I wrote the following piece of code:</p>
  
  <pre><code>class Plane {}
  class Airbus extends Plane {}
  
  public class Main {
  
      void fly(Plane p) {
          System.out.println("I'm in a plane");
      }
  
      void fly(Airbus a) {
          System.out.println("I'm in the best Airbus!");
      }
  
      public static void main(String[] args) {
  
          Main m = new Main();
  
          Plane plane = new Plane();
          m.fly(plane);
  
          Airbus airbus = new Airbus();
          m.fly(airbus);
  
          Plane planeAirbus = new Airbus();
          m.fly(planeAirbus);
  
      }
  }
  </code></pre>
  
  <p>And the result is:</p>
  
  <pre><code>I'm in a plane
  I'm in the best Airbus!
  I'm in a plane
  </code></pre>
  
  <p>Unsurprisingly the two first invocations give <code>I'm in a plane</code> and <code>I'm in the best Airbus!</code> respectively.</p>
  
  <pre><code>Plane planeAirbus = new Airbus();
  </code></pre>
  
  <p>The method treats this object as a Plane, even though the real object is an Airbus. Even when I add <code>abstract</code> to  <code>class Plane</code>, nothing changes and the result of last invocation is still <code>I'm in a plane</code></p>
  
  <p>So the question is why polymorphism doesn't work in method arguments and invocations? Is there any purpose of that? How does it work? </p>