title: Question about overwritten methods in classes that extend each other.
body: <p>I'm studying for a Java-exam and have a question concerning static and dynamic types.</p>
  
  <p>I've got 4 classes: A, B, C and Main. </p>
  
  <pre><code>public class A {
     private void tell(){
     System.out.println("AA");
      }
  }
  
  public class B extends A {
  public void tell(){
      System.out.println("BB");
  }
  }
  
  public class C extends B {
  
  }
  
  public class Main{
  public static void main(String[] args) {
      A c = new C();       
      c.tell();
  }
  
  }
  </code></pre>
  
  <p>My suggestion was: the output should be "BB", because c has the dynamic type C. Since C doesn't have the method "tell" the method of the upper class B is used, which prints "BB".</p>
  
  <p>The outcome however is an error, because Java looks for "tell" in A. In A it of course can't find it, because there it is declared priavte. But why does it look in A, although only it's static type is A, but it's dynamic type is C? </p>