Menu
Question Index
...

What is the output of the following program?

public class ClazzTest {
    static MyClass o1 = new MyClass(100);
    MyClass o2 = new MyClass(200);
    public static void main(String[] args) {
        new MyClass(300);
        new MyClass();
    }
    static MyClass o5 = new MyClass(400);
}
class MyClass {
    public MyClass() {  }
    public MyClass(int i) { System.out.print(i + " ");  }
}


100 300 400
100 200 300 400
100 400 200 300
100 400 300
Compilation Error

Doubts

Problems

Topic: Static and Non Static Variables - Static and Non Static Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App