题目内容

下列Java程序运行后,y的值是?int x = 2;int y = 3;switch (x) {default:y++;case 3:y++;break;case 4:y++;}

A. 2
B. 3
C. 4
D. 5

查看答案
更多问题

下列Java程序运行后,y的值是?int x = 2;int y = 3;switch (x) {default:y++;case 3:y++;case 4:y++;}

A. 2
B. 3
C. 5
D. 6

分析下列Java代码的执行结果是?int i = 2;switch (i) {case 0:System.out.print("0");case 1:System.out.print("1");case 2:System.out.print("2");case 3:System.out.print("3");break;default:System.out.print("default");}

A. 01
B. 12
C. 23
D. default

下列关于switch语句中default的位置说法正确的是?

A. 只能放在最后
B. 必须放在中间
C. 可以放在最后
D. 可以放在任意位置,建议放在最后。

下列选项中关于变量x的定义中,哪两项可使以下的switch语句编译通过。switch(x){case 100:System.out.println("One hundred");break;case 200:System.out.println("Two hundred");break;case 300:System.out.println("Three hundred");break;default:System.out.println("default");}

A. double x=100;
B. char x=100;
C. String x="100";
D. int x=100;

答案查题题库