更多“以下程序段的输出结果为()。int j=2switch (j){Case 2:system.out.print("two."):Case 2+1:System ”相关问题
  • 第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题:

    下列程序的输出结果是 for(int i=0;i<5;i++){ switch(i){ case 0:System.out.print("B"); case 1:System.out.print("e");break; case 2:System.out.print("g"); case 3:System.out.print("!");break; case 4:System.out.print("!");break; default:System.out.print("!"); } }

    A.Beg!!!

    B.Beeg!

    C.Beg!

    D.Beeg!!!


    B

  • 第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 a=0; while(a<5){ switch(a){ case 0: case 3:a=a+2; case 1: case 2:a=a+3; default:a=a+5; } } System.out.print(a);

    A.0

    B.5

    C.10

    D.其他


    因为没有给k赋初值,因此程序不能通过编译

  • 第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