Q:

What is the output of the following java program (Constructor Chaining) ?

0

What is the output of the following java program (Constructor Chaining) ?

class Parent
{
    public Parent()
    {
        System.out.println("Parent class no-args constructor called");
    }
    public Parent(String name)
    {
        System.out.println("Parent class Parameterized constructor called by "+name);
    }
}
public class Child extends Parent
{
    public Child()
    {
        this("JIP");
        System.out.println("Child class no-args constructor called");
    }
    public Child(String name)
    {
        super("JIP");
        System.out.println("Child class Parameterized constructor called by "+name);
    }
    public static void main(String args[])
    {
        Child c = new Child();
    }
}

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

output:

Parent class Parameterized constructor called by JIP

Child class Parameterized constructor called by JIP

Child class no-args constructor called

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now