What will be the output of the following code?

Last Updated :
Discuss
Comments

What will be the output of the following code?

Java
class Base {
    Base() {
        System.out.println("Base Constructor");
    }
}
class Derived extends Base {
    Derived() {
        System.out.println("Derived Constructor");
    }
}
public class Main {
    public static void main(String[] args) {
        Derived obj = new Derived();
    }
}


Base Constructor
Derived Constructor

Derived Constructor
Base Constructor


Compilation Error

Runtime Error

Share your thoughts in the comments