Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 112

Given:

and

What is the result?

    Correct Answer: C

    When the ConSub object is instantiated with the value 4, the ConSub(int a) constructor is called, printing '4'. Since there are no chained calls within ConSub(int a), no other constructors in ConSub are invoked. However, this constructor implicitly calls the superclass (ConSuper) constructor. The corresponding ConSuper(int a) constructor then prints '2'. The output is therefore '234', as the ConSuper() prints '3' after calling ConSuper(int a) with 'this(2)'.

Discussion
ObaltOption: C

Correct answer is C

ASPushkinOption: C

answer: C Automatic invocation of a superclass constructor must be the first line in the subclass constructor. Doesn't matter parameterized or not. //default constructor not inserted class ConSub ConSub() { this(4) } //default constructor is inserted ConSub(int a) { System.out.println(a); } //default constructor not inserted // default class ConSuper - ok // protected constructor - ok class ConSuper { protected ConSuper() { this(2); System.out.println("3"); } //default constructor is inserted class ConSuper { protected ConSuper(int a) { System.out.println(a); } Object default constructor >2 >23 >234

d7bb0b2Option: C

C is correct

TheOneAboveAllOption: C

Tested : C

OmnisumemOption: C

Tested: C.

StavokOption: C

C is correct Tested