Java Reference
In-Depth Information
11. System.out.print(“Congratulations”);
12. default :
13. System.out.print(“Invalid year”);
14. }
15. }
16. }
A.
See you next year
B.
Congratulations
C.
CongratulationsInvalid year
D.
Invalid year
E.
The code does not compile.
4.
Given the following class definition:
1. public class PickAColor {
2. enum Color {RED, BLUE, GREEN}
3.
4. public static void go(Color c) {
5. switch(c) {
6. case RED :
7. System.out.print(“red”);
8. case BLUE :
9. System.out.print(“blue”);
10. break;
11. case GREEN :
12. System.out.print(“green”);
13. default :
14. assert false;
15. }
16. }
17.
18. public static void main(String [] args) {
19. go(Color.RED);
20. }
21. }
what is the result of the following command line?
java -ea PickAColor
A.
red
B.
redblue
C.
redblue, followed by an AssertionError
D.
Compiler error on line 5
E.
Compiler errors on line 6, 8, and 11
Search WWH ::
Custom Search