Java Program to Show Inherited Constructor Calls Parent Constructor By Default Last Updated : 28 Jan, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report In java, there exists a very important keyword known as super() keyword in java which is widely used in java being object-oriented and hence inheritance comes into play. So whenever we use super keyword inside a child constructor then it calls the default parent constructor by itself. Example 1 Java // Java Program to Demonstrate Inherited constructor // calls the parent constructor by default // Class 1 // Main class class GFG { public static void main(String[] a) { // Inherited constructor calling new child(); new parent(); } } // Class 2 // Parent class - Helper class class parent { // Constructor of parent class parent() { System.out.println("I am parent class constructor"); } } // Class 3 // Child class - Helper class class child extends parent { // Constructor of child class child() { System.out.println("I am child class constructor"); } } OutputI am parent class constructor I am child class constructor I am parent class constructor Example 2 Java // Java Program to Demonstrate Inherited constructor // calls the parent constructor by default // Class 1 // Main class class GFG { // Main driver method public static void main(String[] a) { // Inherited constructor calling new child(); new child(100); } } // Class 2 // Parent class (Helper class) class parent { // Constructor of parent class parent() { // Print statement System.out.println("I am parent class constructor"); } } // Class 3 // Child class (Helper class) class child extends parent { // Constructor 1 // Constructor of child class child() { // Print statement System.out.println("I am child class constructor"); } // Constructor 2 // Constructor of child class child(int x) { // Print statement System.out.println( "I am param child class constructor"); } } OutputI am parent class constructor I am child class constructor I am parent class constructor I am param child class constructor Comment More infoAdvertise with us Next Article Java Program to Use Method Overriding in Inheritance for Subclasses D dattabikash505 Follow Improve Article Tags : Java Java Programs Blogathon Blogathon-2021 Java-Constructors +1 More Practice Tags : Java Similar Reads Java Program to Illustrate the Availability of Default Constructor of the Super Class to the Sub Class by Default A constructor in Java is a special method that is used to initialize an object. Whenever an object is created using the new() keyword at least one construction is called. The constructor name must match with the class name and cannot have a return type. If there is no constructor available in the cl 5 min read Java Program to Check if a Given Class is an Inner Class Inner class is a member of another class which is basically a non-static nested class i.e. if a class is inside another class and is not static, then the class is called is referred to as an inner class. Types of Inner Classes: Nested Inner classMethod Local inner classesAnonymous inner classesStati 5 min read Java Program to Use Method Overriding in Inheritance for Subclasses Method overriding in Java is when a subclass implements a method that is already present inside the superclass. With the help of method overriding we can achieve runtime polymorphism. When we are overriding a method then we must keep three things in mind. The method in the subclass must have the sam 5 min read Can We Define a Method Name Same as Class Name in Java? We can have a method name same as a class name in Java but it is not a good practice to do so. This concept can be clear through example rather than explanations. In the below example, a default constructor is called when an object is created and a method with the same name is called using obj.Main( 3 min read Java Program to Show the Nesting of Methods In java, the methods and variables which we create in a class can only be called by using the object of that class or, in case of static methods, we can directly call it by using the name of the class. The methods and variables can be called with the help of the dot operator. But there is a special 5 min read Inheritance of Interface in Java with Examples Inheritance is an important pillar of OOPs(Object Oriented Programming). It is the mechanism in java by which one class is allowed to inherit the features(fields and methods) of another class. Like a class , an interface can have methods and variables, but the methods declared in an interface are by 9 min read Like