单选题1. public class ForBar  {  2. public static void main(String []args)   {  3.   int i = 0, j = 5;  4. tp: for (;;)  {  5. i ++;  6. for(;;)  7. if(i > --j) break tp;  8. }  9. system.out.printIn(“i = ” + i + “, j = “+ j);  10. }  11. }   What is the res

题目
单选题
1. public class ForBar  {  2. public static void main(String []args)   {  3.   int i = 0, j = 5;  4. tp: for (;;)  {  5. i ++;  6. for(;;)  7. if(i > --j) break tp;  8. }  9. system.out.printIn(“i = ” + i + “, j = “+ j);  10. }  11. }   What is the result?()
A

 The program runs and prints “i=1, j=0”

B

 The program runs and prints “i=1, j=4”

C

 The program runs and prints “i=3, j=4”

D

 The program runs and prints “i=3, j=0”

E

 An error at line 4 causes compilation to fail.

F

 An error at line 7 causes compilation to fail.


相似考题
更多“单选题1. public class ForBar  {  2. public static void main(String []args)   {  3.   int i = 0, j = 5;  4. tp: for (;;)  {  5. i ++;  6. for(;;)  7. if(i  --j) break tp;  8. }  9. system.out.printIn(“i = ” + i + “, j = “+ j);  10. }  11. }   What is the resu”相关问题
  • 第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.5

    B.3

    C.8

    D.0


    正确答案:D

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

    B.2

    C.3

    D.4


    正确答案:C

  • 第3题:

    以下程序的输出结果为( )。 public class Main { public static void main(String[] args) { int i=0, j=0, a=6; if((++i>0)||(++j>0)) a++; System.out.println( "i=" +i+", j ="+j+", a="+A; } }

    A.i=0, j=0, a=6

    B.i=1, j=1, a=7

    C.i=1, j=0, a=7

    D.i=0, j=1, a=7


    正确答案:C
    解析:因为表达式(++i>0)先进行了i自增1的运算,所以i的值不可能为0。因此答案 A和D都不对。因为表达式(++i>0)的值为“真”,对于“或”运算来说只要运算符“||”左边的值为“真”,已确定了整个表达式的值为“真”,因而不再去做“||”运算符右边的运算,所以++j的运算并未进行。因此,答案C是正确的输出结果。

  • 第4题:

    下列语句执行后,i的值是( )。 public class Test { public static void main(String[ ] args) { int i =0; for(int j=10; j>5&&i<5; j-=3,i+=2) i=i+j; System.out.println(i); } }

    A.8

    B.9

    C.10

    D.12


    正确答案:D
    解析:变量i和j的初始值分别为0和10,判断结束条件j>5&&i5为true,执行i=i+j;得到i=10,再做j-=3和i+=2,分别得到i=12和j=7,判断结束条件j>5&&i5为false,停止循环,因此i的值为12,正确答案为D。

  • 第5题:

    1. public class ForBar  {  2. public static void main(String []args)   {  3.   int i = 0, j = 5;  4. tp: for (;;)  {  5. i ++;  6. for(;;)  7. if(i > --j) break tp;  8. }  9. system.out.printIn(“i = ” + i + “, j = “+ j);  10. }  11. }   What is the result?()  

    • A、 The program runs and prints “i=1, j=0”
    • B、 The program runs and prints “i=1, j=4”
    • C、 The program runs and prints “i=3, j=4”
    • D、 The program runs and prints “i=3, j=0”
    • E、 An error at line 4 causes compilation to fail.
    • F、 An error at line 7 causes compilation to fail.

    正确答案:A

  • 第6题:

    public class Test {  public static void leftshift(int i, int j) {  i<<=j;  }  public static void main(String args[])  {  int i = 4, j = 2;  leftshift(i, j);   System.out.printIn(i); }  }     What is the result?()  

    • A、 2
    • B、 4
    • C、 8
    • D、 16
    • E、 The code will not compile.

    正确答案:B

  • 第7题:

    public class test(    public int aMethod()[   static int i=0;   i++;   return I;   )    public static void main (String args){   test test = new test();    test.aMethod();   int j = test.aMethod();   System.out.printIn(j);   ]  }   What is the result?()

    • A、 Compilation will fail.
    • B、 Compilation will succeed and the program will print “0”
    • C、 Compilation will succeed and the program will print “1”
    • D、 Compilation will succeed and the program will print “2”

    正确答案:D

  • 第8题:

    public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main (String args[])(   methodA (0);  system.out.printIn(j);  )  )   What is the result?()  

    • A、 The program prints “0”
    • B、 The program prints “4”
    • C、 The program prints “8”
    • D、 The program prints “12”
    • E、 The code does not complete.

    正确答案:B

  • 第9题:

    单选题
    public class ForBar {   public static void main(String args) {   int i = 0, j = 5;   tp: for (;;) {   i ++;   for(;;)   if(i > --j) break tp;   }   system.out.printIn(“i = ” + i + “, j = “+ j);   }   }   What is the result? ()
    A

     The program runs and prints “i=1, j=0”

    B

     The program runs and prints “i=1, j=4”

    C

     The program runs and prints “i=3, j=4”

    D

     The program runs and prints “i=3, j=0”

    E

     An error at line 4 causes compilation to fail.

    F

     An error at line 7 causes compilation to fail.


    正确答案: C
    解析: 暂无解析

  • 第10题:

    单选题
    1. public class ForBar  {  2. public static void main(String []args)   {  3.   int i = 0, j = 5;  4. tp: for (;;)  {  5. i ++;  6. for(;;)  7. if(i > --j) break tp;  8. }  9. system.out.printIn(“i = ” + i + “, j = “+ j);  10. }  11. }   What is the result?()
    A

     The program runs and prints “i=1, j=0”

    B

     The program runs and prints “i=1, j=4”

    C

     The program runs and prints “i=3, j=4”

    D

     The program runs and prints “i=3, j=0”

    E

     An error at line 4 causes compilation to fail.

    F

     An error at line 7 causes compilation to fail.


    正确答案: D
    解析: 暂无解析

  • 第11题:

    单选题
    public class Foo {   public static void main (String []args) {   int i = 1;   int j = i++;   if ((i>++j) && (i++ ==j))  {           i +=j;          }        }      }   What is the final value of i?()
    A

     1

    B

     2

    C

     3

    D

     4

    E

     5


    正确答案: E
    解析: 暂无解析

  • 第12题:

    单选题
    public class Test {  public static void leftshift(int i, int j) {  i<<=j;  }  public static void main(String args[])  {  int i = 4, j = 2;  leftshift(i, j);   System.out.printIn(i); }  }     What is the result?()
    A

     2

    B

     4

    C

     8

    D

     16

    E

     The code will not compile.


    正确答案: C
    解析: 暂无解析

  • 第13题:

    下列程序执行后的结果是______。

    public class ex24

    {

    public static void main(String[] args)

    {

    int j=10;

    a1: for(int i=3;i>0;i--)

    {

    j-=i;

    int m=l;

    a2: while (m<j)

    {

    if (i<=m)

    continue a1;

    j/=m++;

    }

    }

    System.out.println(j);

    }

    }

    下列嵌套的循环程序执行后,结果是______。 public class ax25 { public static void main(String[] args) { int sum=0; for(int i=0;i<=5;i++) { for(int j=10;j>3*i;j--) { sum+=j*i; } } System.out.println(sum); } }

    A.136

    B.127

    C.147

    D.153


    正确答案:C

  • 第14题:

    控制台应用程序 example.java 如下:

    public class example

    {

    public static void main(String[] args)

    {

    int i=0, j=9;

    do

    {

    if(i++>--j) break;

    } while(i<4);

    System.out.println("i="+i+" and j="+j);

    }

    }


    正确答案:
      

  • 第15题:

    下列程序输出结果为( )。 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.0

    B.2

    C.3

    D.4


    正确答案:C

  • 第16题:

    以下程序的运行结果为:public class test {public static void main(String args[]) {int i=0, j=2;do {i=++i;j--;} while(j>0);System.out.println(i);}}

    A. 0

    B. 1

    C. 2

    D.3


    正确答案:C

  • 第17题:

     public class Foo {   public static void main (String []args) {   int i = 1;   int j = i++;   if ((i>++j) && (i++ ==j))  {           i +=j;          }        }      }   What is the final value of i?()  

    • A、 1
    • B、 2
    • C、 3
    • D、 4
    • E、 5

    正确答案:B

  • 第18题:

    public class ForBar {   public static void main(String args) {   int i = 0, j = 5;   tp: for (;;) {   i ++;   for(;;)   if(i > --j) break tp;   }   system.out.printIn(“i = ” + i + “, j = “+ j);   }   }   What is the result? () 

    • A、 The program runs and prints “i=1, j=0”
    • B、 The program runs and prints “i=1, j=4”
    • C、 The program runs and prints “i=3, j=4”
    • D、 The program runs and prints “i=3, j=0”
    • E、 An error at line 4 causes compilation to fail.
    • F、 An error at line 7 causes compilation to fail.

    正确答案:A

  • 第19题:

    public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()  

    • A、 0
    • B、 1
    • C、 2
    • D、 Compilation fails.

    正确答案:D

  • 第20题:

    1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()

    • A、 0
    • B、 3
    • C、 4
    • D、 5
    • E、 The code will not compile.

    正确答案:E

  • 第21题:

    单选题
    1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()
    A

     0

    B

     3

    C

     4

    D

     5

    E

     The code will not compile.


    正确答案: E
    解析: 暂无解析

  • 第22题:

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

    B

     Value = 4

    C

     Value = 5

    D

     Value = 6

    E

     Value = 7

    F

     Value = 8


    正确答案: A
    解析: 暂无解析

  • 第23题:

    单选题
    public class test(  public int aMethod()[  static int i=0;  i++;  return I;  )  public static void main (String args[]){  test test = new test();  test.aMethod();  int j = test.aMethod();  System.out.printIn(j);  ]  }        What is the result?()
    A

     Compilation will fail.

    B

     Compilation will succeed and the program will print “0”

    C

     Compilation will succeed and the program will print “1”

    D

     Compilation will succeed and the program will print “2”


    正确答案: B
    解析: 暂无解析

  • 第24题:

    单选题
    public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main (String args[])(   methodA (0);  system.out.printIn(j);  )  )   What is the result?()
    A

     The program prints “0”

    B

     The program prints “4”

    C

     The program prints “8”

    D

     The program prints “12”

    E

     The code does not complete.


    正确答案: B
    解析: 暂无解析