title: Dynamic binding concern
body: <p>I've really tried to understand it but I couldn't. Why is it printed: <strong><em>Selected: method 1</em></strong> two times?
  I thought that it should be printed</p>
  
  <p><strong><em>Selected: method 1</em></strong></p>
  
  <p><strong><em>Selected: method 2</em></strong></p>
  
  <p>because the real type of c2 is ClassTwo. Please see the code below.</p>
  
  <pre><code>public class ClassOne{}
  
  public class ClassTwo extends ClassOne{}
  
  public class Module {
      public void methodModule(ClassOne c){
          System.out.println("Selected: method 1");
      }
      public void methodModule(ClassTwo c) {
          System.out.println("Selected: method 2");
      }
  }
  
  public class TestModule {
      public static void main(String[] args) {
          Module m = new Module();
          ClassOne c1 = new ClassOne();
          ClassOne c2 = new ClassTwo();
          m.methodModule(c1);
          m.methodModule(c2);
      }
  }
  </code></pre>