Java Program for inheritance using constructor

In this program, You will learn how to implement inheritance using a constructor in Java.

class A { A(){ }}

class Main extends A { Main(){ }}

Example: How to implement inheritance using constructor in Java

Run it Now
class A {

    A() {
        System.out.println("A constructor is called here");

class Main extends A {

    Main() {
        System.out.println("Main constructor is called here");

    public static void main(String args[]) {
        Main obj = new Main();


A constructor is called here
Main constructor is called here