Menu
Question Index
...

What will be the output of the following program?

class ConstructorsTest {
    public static void main(String[] args) {
        T u = new T();
        T u1 = new T(1);
        I v = new I();
        I v1 = new I(1);
        J t = new J();
        J t1 = new J(1);
    }
}
class T {
    I v = new I();
    T() {    System.out.print("t");    }
    T(int i) {    System.out.print("T");    }
}
class I {
    I() {    System.out.print("I");    }
    I(int i) {    System.out.print("i");    }
}
class J extends I {
    J() {    System.out.print("j");    }
    J(int i) {    System.out.print("J");    }
}


ITItiIIJIj
ItITIiIjIJ
ItITIiIJIj
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Inheritance And Constructors 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