Menu
Question Index
...

class ConstructorTest {
    private double i;
    public ConstructorTest(double i) {
        this.t();
        this.i = i;
    }
    public ConstructorTest() {
        System.out.println("Default constructor");
        this(1);
    }
    public void t() {
        System.out.println("Invoking t");
    }
}
Which of the following statement(s) is/are correct?

A. this.t() may be replaced by t()
B. this.i may be replaced by i.
C. this(1) must be called before System.out.println("Default constructor")
D. this(1) must be replaced by this(1.0).


A, B and D
A and C
B, C and D
A and B
Only A
All of them are correct

Doubts

Problems

Topic: Java Access Modifiers With Example Program

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App