Menu
Question Index
...

What will be the output of the following program?

public class Chaining
{
    public Chaining()
    {
        System.out.println("Default constructor");
    }
    public Chaining(int i)
    {
        this();
        System.out.println("Single parameter constructor: " + i);
    }
    public Chaining(int i, int j)
    {
        this(j);
        System.out.println("Double parameter constructor: " + i + ", " + j);
    }
    public static void main(String a[])
    {
        Chaining ch = new Chaining(0, 2);
    }
}


Default constructor
Single parameter constructor: 2
Double parameter constructor: 0, 2
Default constructor
Single parameter constructor: 0
Double parameter constructor: 0, 2
Default constructor
Single parameter constructor: 2
Default constructor
Double parameter constructor: 0, 2
Compilation Error or Runtime Error

Doubts

Problems

Topic: this Keyword In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App