About Question com.enthuware.ets.scjp.v6.2.242 :
Posted: Sun Nov 06, 2016 10:56 am
This seems sneaky!
According to the jls:
https://docs.oracle.com/javase/specs/jl ... ml#jls-3.8
a keyword cannot be used as an identifier, yet here is a snippet that does exactly that.
I went straight for the
It will not compile because of line 1.
It will not compile because of line 3.
options.
According to the jls:
https://docs.oracle.com/javase/specs/jl ... ml#jls-3.8
a keyword cannot be used as an identifier, yet here is a snippet that does exactly that.
Code: Select all
class Test {
public static void doIt( String String ) // 1
{
int i = 10;
i : for (int k = 0 ; k< 10; k++) // 2
{
System.out.println( String + i); //3
if( k*k > 10) continue i; //4
}
}
public static void main(String[] args){
Test.doIt("X");
}
}
It will not compile because of line 1.
It will not compile because of line 3.
options.