- 26
- 0
- 约7.02千字
- 约 11页
- 2017-05-13 发布于贵州
- 举报
4 流程控制、异常断言_有关断言的题不用做
内容概要
练习
流程控制 (if 和 switch)
1. 给出以下代码:
1. public class Switch2 {
2. final static short x = 2;
3. public static int y = 0;
4. public static void main(String [] args) {
5. for (int z=0; z 3; z++) {
6. switch (z) {
7. case y: System.out.print(0 );
8. case x-1: System.out.print(1 );
9. case x: System.out.print(2 );
10. }
11. }
12. }
13. }
哪一项是运行结果?
A. 0 1 2
B. 0 1 2 1 2 2
C. 在第7行编译失败。
D. 在第8行编译失败。
E. 在第9行编译失败。
F. 运行时抛出异常。
2. 给出下面的代码:
1. public class Switch2 {
2. final static short x = 2;
3. public static int y = 0;
4. public static void main(String [] args) {
5. for (int
原创力文档

文档评论(0)