针对下列程序段,需要()个测试用例才可以满足语句覆盖的要求。
switch( value)
case 0;other =30; break;
case 1; other =50; break;
case 2;other=300;
case 3; other =other /value; break;
default:other =other * value;
switch( value)
case 0;other =30; break;
case 1; other =50; break;
case 2;other=300;
case 3; other =other /value; break;
default:other =other * value;
举一反三
- 针对下列程序段,需要(52)个测试用例才可以满足语句覆盖的要求。 switch(value){ case 0: ther=30; break; case 1: ther=50; break; case 2: ther=300; case 3: ther=other/value; break; default: ther=other * value; } A: 2 B: 3 C: 4 D: 5
- 下列程序段的输出结果为______。 int a=2; switch(a) case 2: System.out.println("Value is 2."); case 3: System.out.println("Value is 3."); break; default: System.out.println("end"); break;
- 对以下的switch语句说法正确的是 switch(num){case 1: ...break; case 0: ...break;case 2: ...break; default: ...break; }
- 给出下列的程序段,m为何值时将会输出default switch(m) { case 0: System.out.println("case 0"); case 1:System.out.println("case 1");break; case 2:System.out.println("case 2");break; default:System.out.println("default"); } A: 0 B: 1 C: 2 D: 3
- 若有定义语句int a, b;double x;则下列选项中正确的是( ). A: switch(x%2) { case 0: a++; break; case 1: b++; break; default : a++; b++; } B: switch((int)x/2.0) { case 1: b++; break; case 0: a++; break; default : a++; b++; } C: switch((int)x%2) { case 0: a++; break; case 1: b++; break; default : a++; b++; } D: switch((int)(x)%2) { case 0.0: a++; break; case 1.0: b++; break; default : a++; b++; }