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

Given the code fragment:

What is the result?

    Correct Answer: E

    The compilation fails because the static variable 'y' is not initialized before it is accessed in the constructor. Java requires that all final variables be explicitly initialized. Since 'y' (which is static and final) is not initialized, attempting to access it in the constructor results in a compilation error.

Discussion
d7bb0b2Option: E

E is correct, so compiler marked declaration of y error, but if run program mention that the error is constructor that try to access a variable not initialized

mendjijetOption: E

E is ok Tested line 13 java: variable y might not have been initialized

OmnisumemOption: E

Tested: E.

StavokOption: E

E is correct,

tmuralimanoharOption: E

Answer: E

KiraguJohnOption: C

variable y needs to be initialised