第三章单元测试
  1. 如何更改break语句使退出inner和middle循环,继续外循环的下一轮? 

    outer: for (int x = 0; x < 3; x++) { 

    middle: for (int y = 0; y < 3; y++) { 

    inner: for (int z = 0; z < 3; z++) { 

            if (arr(x, y, z) == targetValue) 

               break;

           }

       }



  2. A: continue; B:break inner; C:break middle; D:break outer;
    答案:break middle;
  3. 以下程序的输出结果为?

    public class Test {

       public static void main(String args[]) {

         for ( int k = 0; k < 3; k++) 

             System.out.print("k");

       } 

    }


  4. A:012 B:0123 C:kkk D:k
  5. 以下代码的调试结果为?

    1:    public class Q10

    2:    {

    3:      public static void main(String[] args)

    4:      {

    5:          int i = 10;

    6:          int j = 10;

    7:          boolean b = false;

    8:          

    9:          if( b = i == j)

    10:            System.out.println("True");

    11:         else

    12:            System.out.println("False");

    13:       }

    14:    }



  6. A:输出 :False B:在第9行出现编译错误 C:输出 :True D:在第9行出现运行异常
  7. 以下代码的调试结果为?

    public class test {

      public static void main(String args[]) { 

        int i = 1;

        do {

            i--;

        } while (i > 2);

        System.out.println(i);

      }

    }


  8. A:0 B:-1 C:1 D:2
  9. 下面的代码段执行之后count的值是什么?

        int count = 0;

        for (int i = 1; i < 4; i++) {

             count += i;

        }

        System.out.println(count);


  10. A:6 B:1 C:10 D:4
  11. 以下程序的运行结果为:

         1. public class Conditional {

         2.    public static void main(String args [] )  {

         3.      int x = 4;

         4.      System.out.println( "value is " +

         5.         ((x > 4)  ? 99.99 : 9));

         6.    }

         7.  }



  12. A:输出:value is 99.99 B:在第5行出现编译错误 C:输出: value is 9 D:输出: value is 9.0
  13. 下列程序的运行结果?

    public class Test {

        public static void main(String a[]) {

            int x=3,y=4,z=5;

            if (x>3) {

              if (y<2)

                System.out.println("show one");

              else

                System.out.println("show two");

             }

             else {

               if (z>4)

                System.out.println("show three");

              else

                System.out.println("show four");

             }

        }

    }


  14. A:show two B:show four C: show three D:show one
  15. 以下程序调试结果 

    public class test {

       public static void main(String args[]) { 

          int i=1, j=3;

          while (j>0) {

             j--;

             i++;         

          } 

          System.out.println(i);

       }

    }


  16. A:4 B:2 C:0 D:3
  17. 在switch(expression)语句中,expression的数据类型不能是?


  18. A:double B:char C:boolean D:byte
  19. 假设a是int类型变量,并初始化为1,则下列哪个为合法的条件语句?


  20. A:if (a) { } B:if (a=2) { } C: if (a<3) { } D: if (true) { }

温馨提示支付 ¥3.00 元后可查看付费内容,请先翻页预览!
点赞(1) dxwkbang
返回
顶部