关于以下程序哪条叙述正确?1. int j = 2;2. switch ( j ) {3. case 2:4. System.out.println ("value is two");5. case 2 + 1:6. System.out.println ("value is three");7. break;8. default:9. System.out.println("value is " + j);10. break;11. }A. 第5行的表达式不合法;B. 变量j是可接受的,switch中表达式可以是byte, short, int,或long的任何类型;C. 输出为value is twoD. 输出是value is two 后跟value is threeE. 输出是value is two 后跟 value is 2

关于以下程序哪条叙述正确?

1. int j = 2;

2. switch ( j ) {

3. case 2:

4. System.out.println ("value is two");

5. case 2 + 1:

6. System.out.println ("value is three");

7. break;

8. default:

9. System.out.println("value is " + j);

10. break;

11. }

A. 第5行的表达式不合法;

B. 变量j是可接受的,switch中表达式可以是byte, short, int,或long的任何类型;

C. 输出为value is two

D. 输出是value is two 后跟value is three

E. 输出是value is two 后跟 value is 2


相关考题:

以下程序的输出结果是 【 9 】 。#includestdio.hmain(){ int j,a[]={1,3,5,7,9,11,13,15},*p=a+5;for(j=3;j;j--){ switch(j){ case 1:case 2:printf( " %d " ,*p++); break;case 3:printf( " %d " ,*(--p));}}}

以下程序的输出结果是( )。 define PR(ar)printf("ar=%d”,ar) main() {int j,a[]={1,8,3,7,6,13,17,15},*p=a+5; for(j=3;j;j--) switch(j) {case 1: case 2:PR(*p++);break; case 3:PR(*(--p)); } }

以下程序段的输出结果为 ( )int j=2;switch(j){case 2:System.out.print("two.");case 2+1:System.out.println("three.");breakdefault:System.out.println("value is"+j);break;}A.two.three.B.two.C.three.D.value is 2

以下程序的输出结果是【 】。include main() {int j,a[]={1,3,5,7,9,11,13,15},*P=a+5; f 以下程序的输出结果是【 】。include <stdio.h>main(){ int j,a[]={1,3,5,7,9,11,13,15},*P=a+5;for(j=3; j;j-){ switch(i){ case 1:case 2: printf("%d",*p++); break;case 3: printf("%d",* (-p));}}}

以下代码的输出结果是什么? class Foo{ public static void main(String args[]){ int x=4,j=0; switch(x){ case 1:j++; case 2:j++; case 3:j++; case 4:j++; case 5:j++; break; default:j++; } System.out.println(j); } }()A.1B.2C.3D.编译错误

以下程序的输出结果是()。includevoid main(){int a(5),b(6),i(0),j(0);switch(a) { 以下程序的输出结果是( )。 #include<iostream.h> void main() { int a(5),b(6),i(0),j(0); switch(a) { case 5:switch(b) { case 5:i++;break; case 6:j++;break; default:i++;j++; } case 6:i++; j++; break; default:i++;j++; } cout<<i<<","<<j<<endl; }A.1,2B.1,3C.2,2D.2,3

下列选项中哪一个编译不出现错误 ( )A.int i=0; if(i){ System.out.println("Hi"); }B.int il=5; int i2=5; if(i1=i2){ System.out.println("So true"); }C.int i=1; int j=2; if(i==1||j==2) System.out.println("OK");D.int i=1; int j=2; if (i==1 |j==2) System.out.println("OK");

publicclassTest{publicstaticvoidmain(StringArgs[]){inti=1,j=0;switch(i){case2:j+=6;case4:j+=1;default:j+=2;case0:j+=4;}System.out.println(j=”+j);}}Whatistheresult?() A.0B.2C.4D.6E.9F.13

inti=1,j=-1;switch(i){case0,1:j=1;case2:j=2;default;j=0;}System.out.println(j=”+j);Whatistheresult?() A.j=-1B.j=0C.j=1D.j=2E.Compilationfails.

publicclassSwitchTest{publicstaticvoidmain(String[]args){System.out.println(value=+switchIt(4));}publicstaticintswitchIt(intx){intj=1;switch(x){case1:j++;case2:j++;case3:j++;case4:j++;case5:j++;default:j++;}returnj+x;}}Whatistheresult?()A.value=3B.value=4C.value=5D.value=6E.value=7F.value=8

下面程序的运行结果是( )。 define P(A)printf("%d",A)main() {int j,a[]={1,2,3,4,5,6,7},i=5; for(j=3;j>1;j--) {switch(j) {case 1: case 2:P(a[i++]);break; case 3:P(a[--i]); } } }

下列程序的输出的结果是______。 public class exl6 { public static void main(String[] args) { int j=10; for(int i=0;i<3;i++) { j-=i+1; switch (j){ case 3: break; case 5: break; case 8: break; default: j=0;break; } } System,out.println(j); } }A.5B.3C.8D.0

请阅读以下程序 main( ) { int x=1.y=0, a=0, b=0: switch(x) { case 1: switch(y) { case 0: a++; break; case 1: b++; break; } case 2: a++; b++; break; } cout<<"a="<<a<<"b="<<bend1; } 上面程序的输出结果是A.a=2, b=1B.a=1, b=1C.a=1. b=0D.a=2. b=2

下列程序输出结果为( )。 public class test { public static void main (String args[]) { int a=0; outer:for(int i=0;i<2;i + +) { for(int j=0;j<2;j+ +) { if(j>i) { continue outer; } a+ +; } } System.out.println(a); } }A.0B.2C.3D.4

下列程序执行后,k的值是 public class Testddd{ public static void main(String args[ ]) { inti;10,j=18 K=30; switch(j-i) { case 8:k++; case 9:k+ =2; case 10:k+ =3; default:k/=j; } System.out.println(k); } }A.31B.32C.2D.33

以下程序的运行结果为?class test {public static void main(String args[]) {int i,j=0;for(i=10;iswitch(j) {case (0) : j=j+1;case ( 1、 : j=j+2; break;case ( 2、: j=j+3; break;case (10) : j=j+10; break;default : break;}System.out.println(j);}}A. 0B. 1C. 2D. 3E. 10

写出程序的运行结果。 #include main( ) { int i=0,j=0,k=0,m; for ( m=0;m4;m++ ) switch ( m ) { case 0:i=m++; case 1:j=m++; case 2:k=m++; case 3:m++; } printf ("/n%d,%d,%d,%d",i,j,k,m); } 该程序的执行结果是()。A、0,1,2,5B、0,1,2,4C、0,1,1,3D、0,1,2,3

int I=1, j=0   switch(i) {   case 2:   j+=6;   case 4:   j+=1;    default:    j +=2;   case 0:   j +=4;   }   What is the value of j at line 16?()A、 0B、 1C、 2D、 4E、 6

public class SwitchTest {  public static void main(String[] args) {  System.out.println(“value = “ + switchIt(4));  }  public static int switchIt(int x) {  int j = 1;  switch (x) {  case 1: j++; case 2: j++;  case 3: j++;  case 4: j++;  case 5: j++;  default: j++;  }  return j + x; }  }  What is the result?()  A、 value = 3B、 value = 4C、 value = 5D、 value = 6E、 value = 7F、 value = 8

public class Test {  public static void main(String Args[]) {  int i =1, j = 0;  switch(i) {  case 2: j +=6;  case 4: j +=1;  default: j +=2;  case 0: j +=4;  }  System.out.println(“j =” +j);  }  }  What is the result? () A、 0B、 2C、 4D、 6E、 9F、 13

int i = 1,j = -1;  switch (i) {  case 0, 1:j = 1;  case 2: j = 2;  default; j = 0;  }  System.out.println(“j=”+j);  What is the result?()  A、 j = -1B、 j = 0C、 j = 1D、 j = 2E、 Compilation fails.

1. int I=1, j=0  2.    3. switch(i)  {  4. case 2:  5. j+=6;  6.    7. case 4:  8. j+=1;  9.    10. default:  11. j +=2;  12.    13. case 0:  14. j +=4;  15. }  16.      What is the value of j at line 16?()A、 0B、 1C、 2D、 4E、 6

单选题int i = 1,j = -1;  switch (i) {  case 0, 1:j = 1;  case 2: j = 2;  default; j = 0;  }  System.out.println(“j=”+j);  What is the result?()A j = -1B j = 0C j = 1D j = 2E Compilation fails.

单选题public class SwitchTest {   public static void main (String args) {   System.out.PrintIn(“value =” +switchIt(4));   }   public static int switchIt(int x) {   int j = 1;   switch (x) {   case 1: j++;   case 2: j++;   case 3: j++;  case 4: j++;   case 5: j++;   default:j++;   }   return j + x;   }   }   What is the output from line 3? ()A Value = 3B Value = 4C Value = 5D Value = 6E Value = 7F Value = 8

单选题1. public class SwitchTest {  2. public static void main (String []args)  {  3. System.out.PrintIn(“value =” +switchIt(4));  4. }  5. public static int switchIt(int x)  {  6. int j = 1;  7. switch (x) {  8. case 1: j++;  9. case 2: j++;  10. case 3: j++;  11. case 4: j++;  12. case 5: j++;  13. default:j++;  14. }  15. return j + x;  16. }  17. }     What is the output from line 3?()A Value = 3B Value = 4C Value = 5D Value = 6E Value = 7F Value = 8

单选题public class SwitchTest {  public static void main(String[] args) {  System.out.println(“value = “ + switchIt(4));  }  public static int switchIt(int x) {  int j = 1;  switch (x) {  case 1: j++; case 2: j++;  case 3: j++;  case 4: j++;  case 5: j++;  default: j++;  }  return j + x; }  }  What is the result?()A value = 3B value = 4C value = 5D value = 6E value = 7F value = 8

单选题public class Test {  public static void main(String Args[]) {  int i =1, j = 0;  switch(i) {  case 2: j +=6;  case 4: j +=1;  default: j +=2;  case 0: j +=4;  }  System.out.println(“j =” +j);  }  }  What is the result? ()A 0B 2C 4D 6E 9F 13