参考答案和解析
参考答案:E
更多“inti=1,j=-1;switch(i){case0,1:j=1;case2:j=2;default;j=0;}System.out.println(j=”+j);Whatistheresult?() ”相关问题
  • 第1题:

    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


    程序编译出错

  • 第2题:

    已知int i=1,j=0;执行下面语句后j的值是____。 while(i) switch(i) { case 1: i+=1;j++;break; case 2: i+=2;j++;break; case 3: i+=3;j++;break; default: i--;j++; break; }

    A.1

    B.2

    C.3

    D.死循环


    死循环

  • 第3题:

    3、给定下面程序段,输出结果是()。 int i= 1, j = 0; switch(i){ case 1 : j += 6; case 2 : j += 1; default : j += 2; } System.out.println(j); A.2 B.6 C.7 D.9


    1 5 9

  • 第4题:

    已知int i=1,j=0;执行下面语句后j的值是____。    while(i) switch(i) { case 1: i+=1;j++;break; case 2: i+=2;j++;break; case 3: i+=3;j++;break; default: i--;j++;break;}

    A.死循环

    B.1

    C.2

    D.3


    死循环

  • 第5题:

    4、给定程序段,求输出结果。 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);

    A.6

    B.1

    C.2

    D.4


    6