title: Upcasting Objects - difference of static and non-static type
body: <p>I have the following java code:</p>
  
  <pre><code>class A {
   int someMethod () { return 1; }
   int someMethod (A a) { return 2; }
   int someMethod (B b) { return 3; }
   int someMethod (C c) { return 4; }
   static A anotherMethod ( Object obj) { return (A) obj; }
   }
  
  class B extends A {
   int someMethod () { return 6; }
   int someMethod (A a) { return 7; }
   int someMethod (B b) { return 8; }
   int someMethod (C c) { return 9; }
   static A anotherMethod ( Object obj) { return (B) obj; }
   }
  
   class C extends A {
   int someMethod () { return 11; }
   int someMethod (A a) { return 12; }
   int someMethod (B b) { return 13; }
   int someMethod (C c) { return 14; }
   static C anotherMethod ( Object obj) { return (C) obj; }
   }
  
  public static void main ( String [] args ){
   A a = new A(); B b = new B(); C c = new C();
   System .out. println (A. anotherMethod (b). someMethod (b));
  }
  </code></pre>
  
  <p>As expected the output is 8.</p>
  
  <p>Ok now i delete the someMethod(B b) in class A:</p>
  
  <pre><code>class A {
   int someMethod () { return 1; }
   int someMethod (A a) { return 2; }
   int someMethod (C c) { return 4; }
   static A anotherMethod ( Object obj) { return (A) obj; }
  }
  </code></pre>
  
  <p>I discussed the output with my friends, but nobody could explain exactly why we get a 7 as output now?!?!???</p>