|2||Constructors Output Test|
|13||Sub And Super Classes|
|15||this and super|
|17||CPU and MotherBoard|
|19||Creating classes inside other class1636|
|23||Constructors and inheritance|
What will be the output of the following program?
Correct Answer : C
We can recall that when a subclass constructor is called, default constructors of the superclass are called first and then the subclass constructor. Here when
Alpha is called, the superclass constructor that is
Base will be called first and then
Alpha will be called.
new Alpha() is called, Base is printed. As println is used, cursor goes to next line and then again Base is printed by display statement in
new Base() is called again Base is printed in same line as previously we used
println. So cursor remains in the same line.
Hence, the answer is C.