Given:
What is the result?
A. A compilation error occurs in the modify method.
B. 99
C. 5
D. A compilation error occurs in the main method.
Given:
What is the result?
A. A compilation error occurs in the modify method.
B. 99
C. 5
D. A compilation error occurs in the main method.
Correct Anwser is A. (“final int l” … text font makes the lower case “L” look like a 1)
the variable 1 (which starts with a number) is used as a field name in the TestFinal class. This is not a valid identifier, so the compiler will report a compilation error at this line:
final int 1 = 5;
Additionally, since the modify() method tries to modify this invalid identifier 1, it will also result in a compilation error:
test.1l = 99;
Finally, the main() method tries to access this invalid identifier 1 in the following line:
System.out.println (tf.1);
The compilation error is in both the modify method and the main method due to the variable name 1 being an invalid identifier in Java.