Given the code fragment:
What is the result?
Given the code fragment:
What is the result?
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.
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
E is ok Tested line 13 java: variable y might not have been initialized
Tested: E.
E is correct,
Answer: E
variable y needs to be initialised