title: Why I'm not warned of this problem?
body: <p>Suppose I have two classes defined the following way:</p>
  
  <pre><code>public class A {
  
     public A() {
        foo();
     }
  
     public void foo() {
        System.out.println("A");
     }
  }
  
  public class B extends A {
  
     private String bar;
  
     public B() {
        bar = "bar";
     }
  
     @Override
     public void foo() {
        System.out.println(bar);
     }
  
  }
  </code></pre>
  
  <p>And then i instantiate B the following way:</p>
  
  <pre><code>A test = new B();
  </code></pre>
  
  <p>So why can't the compiler respectively the IDE warn me that there will be a NullPointer in the foo method of B? That wouldn't be to difficult to check and sometimes very useful.</p>