Exam 1z0-808 All QuestionsBrowse all questions from this exam
Question 27

Given:

What is the result?

    Correct Answer: C

    When a new instance of class C is created, the constructor of class C is called first. But before any code in the constructor of class C is executed, the constructor of its superclass (class B) is called due to the implicit call to super(). This process continues up the inheritance chain, resulting in the constructor of class A being called first, followed by the constructor of class B, and finally, the constructor of class C. Hence, the output is 'A B C'.

Discussion
M_JawadOption: C

the super method is called by default : first : constructor A is called. second : constructor B . Finally constructor C.

M_JawadOption: C

Answer is C

SSJ5Option: C

Correct answer is C

v323rsOption: C

The correct answer is C "A B C"

mete23Option: C

The correct answer is C class A { public A() { System.out.println("A "); } } class B extends A { public B() { System.out.println("B "); } } class C extends B { public C() { System.out.println("C "); } public static void main(String[] args) { C c = new C(); } }

AhmadTechieOption: C

Answer is C compiler add super() as first statement in constructor . hence super class constructor gets called and super class initialized before child class

duydnOption: C

super() added by JVM -> C is the correct one.

Dolly2901Option: C

by default compiler puts super() at first line inside any constructor. It calls it's super class constructor first. So correct Answer is ABC

Vicky_65Option: C

C is correct

jjgryOption: C

all constructors call empty super constructor by default, before executing their own code

Mamlouk_MedOption: C

correct, implecit super() method execution before each system.out.println of each constructor