title: Program initialises both subclas and superclass constructors at once
body: <p>The superclass:</p>
  <pre><code>public class Modem {
  
  Modem(){
      System.out.println(&quot;The Modem Constructor&quot;);
  }
  
  Modem(String entry){
      System.out.println(&quot;The &quot; +entry);
   }
  }
  </code></pre>
  <p>The subclass:</p>
  <pre><code>public class CableModem extends Modem {
      
      CableModem(String entry){
          System.out.println(&quot;The &quot; + entry);
      }
      
      CableModem(){
          System.out.println(&quot;The CableModem Constructor&quot;);
      }
  }
  </code></pre>
  <p>Main class:</p>
  <pre><code>public class Main {
  
      public static void main(String[] args) {
          CableModem cMod = new CableModem();
          Modem mod = new Modem();
     }
  
  }
  </code></pre>
  <p>The output that i get:</p>
  <blockquote>
  <p>The Modem Constructor</p>
  <p>The CableModem Constructor</p>
  <p>The Modem Constructor</p>
  </blockquote>
  <p>So when I create an object of the subclas, both its and the supperclass constructors are being called. Why is this happening, and how can I prevent it from happening?</p>