Menu
Question Index
...

What will be the output of the following program?

public class InitializationTest {
    int number;
    public void InitializationTest(int number) {
        this.number = number;
        System.out.println(number);
    }
    public static void main(String... strings) {
        InitializationTest obj1, obj2;
        obj1 = new InitializationTest();
        obj2 = new InitializationTest(5);
    }
}


5
Compile time Error since no default constructor
Compile time Error since no parameterized constructor
Compilation Error or Runtime Error for some other reason

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