title: Shadowing static method
body: <p>I was reading about shadowing static methods, and I can't  understand one thing, how compiler chose method to run.
  Suppose I have 3 classes. </p>
  
  <pre><code>public static class A {
          public static int test() {
              return 1;
          }
      }
  
      public static class B extends A {
          public static int test() {
              return 2;
          }
      }
  
      public static class C extends B {
          public static int test() {
              return 3;
          }
      }
  </code></pre>
  
  <p>Obviously when I call method <code>A.test()</code> <code>B.test()</code> <code>C.test()</code> i will have results <code>1</code> <code>2</code> <code>3</code></p>
  
  <p>But if i call it from instance (I know bad practice), then When this code:</p>
  
  <pre><code>C c = new C();
  System.out.println(c.test());
  </code></pre>
  
  <p>will print out 3 as i expect, but when I do</p>
  
  <pre><code>B b = c;
  System.out.println(b.test());
  </code></pre>
  
  <p>then my output will be 2.
  Which is surprising for me, as <code>b</code> was instantiate as object of class <code>C</code>. Any reason why it was implemented like that?</p>