题目内容

下列语句序列执行后,结果是______。switch (5) {default:System.out.print(5);case 0:System.out.print(0);case 1:System.out.print(1);break;case 2:System.out.print(2);break;}

A. 0
B. 1
C. 5
D. 501

查看答案
更多问题

以下代码段所有语句执行完时,变量c与result的值为______boolean a = false;boolean b = true;boolean c= ( a&&b)&&(!b);int result = (c == false)?1:2;

A. false和1
B. true和2
C. true和1
D. false和2

下列选项中,____是以下程序的运行结果。public class SwitchDemo3 {public static void main(String[] args) {char c = 'B';switch (c) {case 'A':System.out.println("优");break;case 'B':System.out.println("良");break;case 'C':System.out.println("差");break;}}}

A. 优
B. 良
C. 差
D. 编译失败

阅读下面程序片段:switch (i) {case 1:System.out.println("message1");case 2:System.out.println("message2");case 3:System.out.println("message3");break;}当变量i的值为______时,程序只输出“message 3”。

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

某商场举行购物优惠活动如下表所示(x 代表购物款),请用switch语句编写程序,对输入的顾客购物款,计算出应付的款数。当 x<1600 时,不打折;当 1600<=x<2400 时打95折;当 2400<=x<3200 时打9折;当 3200<=x<6400 时打85折;当 x>=6400 时打8折。

答案查题题库