title: Why is super class constructor always called
body: <p>I have the following 2 classes</p>
  <pre><code>public class classA {
      classA() {
          System.out.println(&quot;A&quot;);
      }
  }
  
  class classB extends classA {
      classB() {
          System.out.println(&quot;B&quot;);
      }
  }
  </code></pre>
  <p>and then running</p>
  <h1>1</h1>
  <pre><code>classA c = new classB();
  </code></pre>
  <p>or</p>
  <h1>2</h1>
  <pre><code>classB c = new classB(); 
  </code></pre>
  <p>always gives</p>
  <pre><code>A
  B
  </code></pre>
  <p>Why is this happening? At first glance, in either scenario, I would assume that only the <code>classB</code> constructor would be called and thus the only output would be</p>
  <pre><code>B
  </code></pre>
  <p>but this is clearly wrong.</p>