单选题int i = 0;  for (; i <4; i += 2) {  System.out.print(i + “”);  }  System.out.println(i);  What is the result?()A0 2 4B0 2 4 5C0 1 2 3 4DCompilation fails.EAn exception is thrown at runtime.

题目
单选题
int i = 0;  for (; i <4; i += 2) {  System.out.print(i + “”);  }  System.out.println(i);  What is the result?()
A

 0 2 4

B

 0 2 4 5

C

 0 1 2 3 4

D

 Compilation fails.

E

 An exception is thrown at runtime.


相似考题
更多“单选题int i = 0;  for (; i 4; i += 2) {  System.out.print(i + “”);  }  System.out.println(i);  What is the result?()A  0 2 4B  0 2 4 5C  0 1 2 3 4D  Compilation fails.E  An exception is thrown at runtime.”相关问题
  • 第1题:

    有以下程序

    #include<stdio.h>

    main( )

    {int a[]={2,3,5,4},i;

    for(i=0;i<4;i++)

    switch(i%2)

    {case 0:switch(a[i]%2)

    {case 0:a[i]++;break;

    case 1:a[i]--;

    }break;

    case 1:a[i]=O;

    }

    for(i=O;i<4;i++)prinff(“%d”,a[i]);prinff(“\n”);

    }

    程序运行后的输出结果是

    A.3 3 4 4

    B.2 0 5 0

    C.3 0 4 0

    D.0 3 0 4


    正确答案:C
    解析:第一次循环,i=0,i%2=0,a[0]%2=0,a[0]=a[0]+1=3;第二次循环,i=l,1%2=1,a[1]=0;第三次循环,i=2,a[2]%2=l,a[2]=a[2]-1=4;第四次循环,i=3,i%2=1,a[3]=0。

  • 第2题:

    int i = 0, j = 5;  tp;   for (;;) {  i++;  for(;;) {  if (i> --j) {  break tp;  break tp;  }  }  System.out.println(“i=” +i “,j =”+j); } What is the result?()  

    • A、 i = 1, j = 0
    • B、 i = 1, j = 4
    • C、 i = 3, j = 4
    • D、 i = 3, j = 0
    • E、 Compilation fails.

    正确答案:B,D

  • 第3题:

    int i = 0;  while (true) { if(i==4) {  break;  }  ++i;  }  System.out.println(“i=”+i);  What is the result?()  

    • A、 i = 0
    • B、 i = 3
    • C、 i = 4
    • D、 i = 5
    • E、 Compilation fails.

    正确答案:C

  • 第4题:

    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、 0
    • B、 2
    • C、 4
    • D、 6
    • E、 9
    • F、 13

    正确答案:D

  • 第5题:

    public class Delta {  static boolean foo(char c) {  System.out.print(c);  return true;  }  public static void main( String[] argv ) {  int i =0;  for ( foo(‘A’); foo(‘B’)&&(i<2); foo(‘C’)){  i++ ;  foo(‘D’);  }  }  }  What is the result?()  

    • A、 ABDCBDCB
    • B、 ABCDABCD
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:A

  • 第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 = -1
    • B、 j = 0
    • C、 j = 1
    • D、 j = 2
    • E、 Compilation fails.

    正确答案:E

  • 第7题:

    单选题
    int i = 0;  while (true) { if(i==4) {  break;  }  ++i;  }  System.out.println(“i=”+i);  What is the result?()
    A

     i = 0

    B

     i = 3

    C

     i = 4

    D

     i = 5

    E

     Compilation fails.


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

  • 第8题:

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

     0

    B

     2

    C

     4

    D

     6

    E

     9

    F

     13


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

  • 第9题:

    单选题
    int i = 0, j = 1;  if ((i++ == 1) && (j++ == 2)) {  i = 42;  }  System.out.println(“i = “ + i + “, j = “ + j);   What is the result?()
    A

     i = 1, j = 2

    B

     i = 1, j = 1

    C

     i = 42, j = 2

    D

     i = 42, j = 1

    E

     Compilation fails.


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

  • 第10题:

    单选题
    class Computation extends Thread {  private int num;  private boolean isComplete;  private int result;  public Computation(int num) { this.num = num; }  public synchronized void run() {  result = num * 2;  isComplete = true;  notify();  }  public synchronized int getResult() {  while (!isComplete) {  try {  wait();  } catch (InterruptedException e) { }  }  return result;  }  public static void main(String[] args) {  Computation[] computations = new Computation [4];  for (int i = 0; i < computations.length; i++) {  computations[i] = new Computation(i);  computations[i] .start();  }  for (Computation c : computations)  System.out.print(c.getResult() +“ “);  }  }  What is the result?()
    A

     The code will deadlock.

    B

     The code may run with no output.

    C

     An exception is thrown at runtime.

    D

     The code may run with output “0 6”.

    E

     The code may run with output “2 0 6 4‟.

    F

     The code may ruin with output “0 2 4 6”.


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

  • 第11题:

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

    B

     j = 0

    C

     j = 1

    D

     j = 2

    E

     Compilation fails.


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

  • 第12题:

    单选题
    下列代码的执行结果是(  )。int numbers[] = new int[6];for(int i=1;i numbers[i] =i-1;System.out.print(numbers[i]+" ");}
    A

    0 1 2 3 4 5

    B

    1 2 3 4 5 6

    C

    -1 0 1 2 3 4

    D

    0 1 2 3 4


    正确答案: D
    解析:
    上述代码循环对数组numbers中的每一个成员赋值,numbers.1enght=6,循环变量i的范围是1~5,每一个成员的值为i-1,并输出该成员值,因此结果是 0 1 2 3 4 。

  • 第13题:

    public class Test {  public static void add3 (Integer i) {  int val = i.intValue();  val += 3;  i = new Integer(val); }  public static void main(String args[]) {  Integer i = new Integer(0);  add3(i);  System.out.println(i.intValue());  }  }   What is the result? () 

    • A、 0
    • B、 3
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:A

  • 第14题:

    int i = 0, j = 1;  if ((i++ == 1) && (j++ == 2)) {  i = 42;  }  System.out.println(“i = “ + i + “, j = “ + j);   What is the result?()  

    • A、 i = 1, j = 2
    • B、 i = 1, j = 1
    • C、 i = 42, j = 2
    • D、 i = 42, j = 1
    • E、 Compilation fails.

    正确答案:B

  • 第15题:

    class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()  

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

    正确答案:C

  • 第16题:

    public static void main(String[] args) {  for (int i=0;i<= 10;i++){  if( i>6) break;  }  System.out.println(i);  }  What is the result?() 

    • A、 6
    • B、 7
    • C、 10
    • D、 11
    • E、 Compilation fails.
    • F、 An exception is thrown at runtime.

    正确答案:E

  • 第17题:

    int i = 0;  for (; i <4; i += 2) {  System.out.print(i + “”);  }  System.out.println(i);  What is the result?()  

    • A、 0 2 4
    • B、 0 2 4 5
    • C、 0 1 2 3 4
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:A

  • 第18题:

    class Computation extends Thread {  private int num;  private boolean isComplete;  private int result;  public Computation(int num) { this.num = num; }  public synchronized void run() {  result = num * 2;  isComplete = true;  notify();  }  public synchronized int getResult() {  while (!isComplete) {  try {  wait();  } catch (InterruptedException e) { }  }  return result;  }  public static void main(String[] args) {  Computation[] computations = new Computation [4];  for (int i = 0; i < computations.length; i++) {  computations[i] = new Computation(i);  computations[i] .start();  }  for (Computation c : computations)  System.out.print(c.getResult() +“ “);  }  }  What is the result?() 

    • A、 The code will deadlock.
    • B、 The code may run with no output.
    • C、 An exception is thrown at runtime.
    • D、 The code may run with output “0 6”.
    • E、 The code may run with output “2 0 6 4‟.
    • F、 The code may ruin with output “0 2 4 6”.

    正确答案:F

  • 第19题:

    单选题
    import java.util.*;  class KeyMaster {  public int i;  public KeyMaster(int i) { this.i = i; }  public boolean equals(Object o) { return i == ((KeyMaster)o).i; }  public int hashCode() { return i; }  }  public class MapIt {  public static void main(String[] args) {  Set set = new HashSet();  KeyMaster k1 = new KeyMaster(1);  KeyMaster k2 = new KeyMaster(2);  set.add(k1); set.add(k1);  set.add(k2); set.add(k2);  System.out.print(set.size() + “:”);  k2.i = 1;  System.out.print(set.size() + “:”);  set.remove(k1);  System.out.print(set.size() + “:”);  set.remove(k2);  System.out.print(set.size()); }  }  What is the result?()
    A

     4:4:2:2

    B

     4:4:3:2

    C

     2:2:1:0

    D

     2:2:0:0

    E

     2:1:0:0

    F

     2:2:1:1

    G

     4:3:2:1


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

  • 第20题:

    单选题
    public class Delta {  static boolean foo(char c) {  System.out.print(c);  return true;  }  public static void main( String[] argv ) {  int i =0;  for ( foo(‘A’); foo(‘B’)&&(i<2); foo(‘C’)){  i++ ;  foo(‘D’);  }  }  }  What is the result?()
    A

     ABDCBDCB

    B

     ABCDABCD

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


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

  • 第21题:

    单选题
    class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()
    A

     0

    B

     1

    C

     2

    D

     Compilation fails.


    正确答案: B
    解析: This code is perfectly legal and the answer is C. 

  • 第22题:

    单选题
    public static void main(String[] args) {  for (int i=0;i6) break;  }  System.out.println(i);  }  What is the result?()
    A

     6

    B

     7

    C

     10

    D

     11

    E

     Compilation fails.

    F

     An exception is thrown at runtime.


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

  • 第23题:

    单选题
    public class Test {  public static void add3 (Integer i) {  int val = i.intValue();  val += 3;  i = new Integer(val); }  public static void main(String args[]) {  Integer i = new Integer(0);  add3(i);  System.out.println(i.intValue());  }  }   What is the result? ()
    A

     0

    B

     3

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


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