title: Java Inheritance Example
body: <p>Below is the example for Inheritance</p>
  
  <pre><code>class Parent {
      Parent(int a, int b) {
          int c = a + b;
          System.out.println("Sum=" + c);
      }
      void display() {
          System.out.println("Return Statement");
      }
  }
  class Child extends Parent {
      Child(int a, int b) {
          int c = a - b;
          System.out.println("Difference=" + c);
      }
  }
  public class InheritanceExample {
      public static void main(String args[]) {
          Child c = new Child(2, 1);
          c.display();
      }
  }
  </code></pre>
  
  <p>I get the below error when I don't have  the non-parametrized constructor parent()</p>
  
  <pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
      Implicit super constructor Parent() is undefined. Must explicitly invoke another constructor
  
      at Child.&lt;init&gt;(InheritanceExample.java:14)
      at InheritanceExample.main(InheritanceExample.java:22)
  </code></pre>
  
  <p>Can you please explain me what is the purpose of the <strong>constructor without parameters</strong> in base class.</p>