What is the result of the following code snippet? (Choose all that apply.)
3: final int movieRating = 4; 4: int select = 9; 5: switch(select) { 6: case 0: /*from w w w .j a va2 s.c om*/ 7: case select: System.out.println("Awful"); break; 8: case movieRating: System.out.println("Great"); break; 9: case 4: 10: default: 11: case (int)'a': 12: case 1*1: System.out.println("Too be determined"); break; 13: }
B,C.
The code will not compile due to problems with the case values.
First, select is not a constant value; therefore line 6 will not compile.
If it was marked final, it would compile, so B is correct.
Next, Line 9 has the same case value of 4 as Line 8.
Since there's no option to remove Line 8 available in the choices, Line 9 should be removed and C is correct.
The other answers are incorrect, because the rest of the lines of the code compile.