CompileTimeConstant.java:3: error: cannot infer type for local variable v1
var v1;
^
(cannot use 'var' on variable without initializer)
1 error
error: compilation failed
This is indeed a valid statement. But it is the explanation to the option number 4, which is an incorrect option. It explains why option 4 is incorrect.
If you like our products and services, please help us by posting your review here.
This is indeed a valid statement. But it is the explanation to the option number 4, which is an incorrect option. It explains why option 4 is incorrect.
Thank you. You are right. I thought the blue text in review mode was part of the answer. I totally face-palmed myself there.
I am not sure if this is out of scope for the exam or not, but //1 can also be wrong. The TestClass.java file won't run if you run it with "java" and complains that it cannot find the main method.
To run this file, you must compile it first with javac, then run with java.