The answer within the enthuware application is wrong. See code below:
Code: Select all
public class Switcher{
public static void main(String[] args){
switch(Integer.parseInt(args[1])) //1{
case 0 :
boolean b = false;
break;
case 1 :
b = true; //2
break;
}
if(b) System.out.println(args[2]);
}
}
The program cannot be compiled, therefore it cannot be run. It doesn't matter how the question is worded, the code simply does not compile and it would be wrong to ask someone learning Java to temporarily suspend this and postulate on what might otherwise happen.
The correct answer is "It will not compile because of //1."
Code: Select all
[brrees@mnlowdk03273 ~]$ javac Switcher.java
Switcher.java:4: error: '{' expected
switch(Integer.parseInt(args[1])) //1{
^
1 error
Sure, while that statement is indeed correct, the "// 1 {" is not correct and causes a compilation error.
Please correct.