10、给定Java代码片断,如下: int i=0,j=-1; switch(i) { case 0,1:j=1; case 2:j=2; } System.out.print("j="+j); 编译运行,正确的结果是()。A.程序编译出错B.j=1C.j=2D.j=0

10、给定Java代码片断,如下: int i=0,j=-1; switch(i) { case 0,1:j=1; case 2:j=2; } System.out.print("j="+j); 编译运行,正确的结果是()。

A.程序编译出错

B.j=1

C.j=2

D.j=0


参考答案和解析
程序编译出错

相关考题:

publicclasstest3{publicstaticvoidmain(Stringargs[]){for(inti=0;i3;i++){for(intj=3;j=0;j--){if(i==j)continue;System.out.println(i=+i+j=+j);}}}}上面的Java代码编译运行后,下列选项中,()会出现在输出结果中。A.i=0j=3B.i=0j=0C.i=2j=2D.i=0j=2E.i=1j=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)); } }

下列程序段选择项,使i的运行结果为3的程序段是( )。A.int i=0,j=O; (i=2,(j++)+i);B.int i=1,j=0; j=i=((i=3)*2);C.int i=0,j=1; (j=1)?(i=1):(i=3);D.int i=1,j=1; i+=j+=1;

以下程序的输出结果是【 】。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

intI=1,j=02.3.switch(i){4.case2:5.j+=6;6.7.case4:8.j+=1;9.10.default:11.j+=2;12.13.case0:14.j+=4;15.}16.Whatisthevalueofjatline16?() A.0B.1C.2D.4E.6

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.

intI=1,j=0switch(i){case2:j+=6;case4:j+=1;default:j+=2;case0:j+=4;}Whatisthevalueofjatline16?() A.0B.1C.2D.4E.6

下面程序的运行结果是( )。 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]); } } }

运行下列程序时,若输入数据为“321”,则输出结果是( )。 main() {int num,i,j,k,s; scanf("%d",num); if(num>99) s=3; else if(num>9) s=2; else s=1; i=num/100; j=(num-i*100)/10; k=(num-i*100-j*10); switch(s) {case 3:printf("%d%d%d\n",k,j,i); break; case 2:printf("%d%d\n",k,j); case 1:printf("%d\n",k); } }A.123B.1,2,3C.321D.3,2,1

下列程序的输出的结果是______。 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

下列程序的输出结果是【】。 include void main() { inta(5),b(6),i(0)1j(0); switch(a 下列程序的输出结果是【 】。include<iostream.h>void main(){inta(5),b(6),i(0)1j(0);switch(a){case 5:switch(b){case 5:i++;break;case 6:j++;break;defaun:i++;j++;}case 6:i++;j++;break;default:i++;j++;}cout<<i<<","<<j<<endl;}

以下程序运行后的输出结果是【】。include main(){int i=10,j=0;do{j=j+ i; i--;}while 以下程序运行后的输出结果是【 】。include <iostream.h>main(){int i=10,j=0;do{j=j+ i; i--;}while(i>2);cout<<j;}

以下程序的运行结果为?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

以下代码的运行结果为:public class Calc {public static void main (String args []) {int total = 0;for (int i = 0, j = 10; total >30; ++i, --j) {System.out.println(" i = " + i + " : j = " + j);total += (i + j);}System.out.println("Total " + total);}}A. 产生运行错误B. 产生编译错误C. 输出 "Total 0"D. 产生如下输出:i = 0 : j = 10i = 1 : j = 9i = 2 : j = 8Total 30

public class test3  {  public static void main(String args[])  {           for(int i = 0; i  3; i++)  {  for(int j = 3; j = 0; j--)  {                if(i == j)                    continue;       System.out.println("i="+ i + " j="+j);       }    }       }  }  上面的Java代码编译运行后,下列选项中,()会出现在输出结果中。 A、i=0 j=3B、i=0 j=0C、i=2 j=2D、i=0 j=2E、i=1 j=2

写出程序的运行结果。 #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 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.

单选题写出程序的运行结果。 #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); } 该程序的执行结果是()。A0,1,2,5B0,1,2,4C0,1,1,3D0,1,2,3

多选题public class test3  {  public static void main(String args[])  {           for(int i = 0; i = 0; j--)  {                if(i == j)                    continue;       System.out.println("i="+ i + " j="+j);       }    }       }  }  上面的Java代码编译运行后,下列选项中,()会出现在输出结果中。Ai=0 j=3Bi=0 j=0Ci=2 j=2Di=0 j=2Ei=1 j=2

单选题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