CMS专题

单选题What will be the result of attempting to compile and run the following program?()   public class Q28fd {   public static void main(String args[]) {   int counter = 0;   l1:   for (int i=10; i i) break l2;   if (i == j) {   counter++;   continue l1;   }

题目
单选题
What will be the result of attempting to compile and run the following program?()   public class Q28fd {   public static void main(String args[]) {   int counter = 0;   l1:   for (int i=10; i i) break l2;   if (i == j) {   counter++;   continue l1;   }   }   counter--;   }   System.out.println(counter);  }   }
A

The program will fail to compile.

B

The program will not terminate normally.

C

The program will write 10 to the standard output.

D

The program will write 0 to the standard output.

E

The program will write 9 to the standard output.

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

class MyThread extends Thread {  public void run() { System.out.println(“AAA”); }  public void run(Runnable r) { System.out.println(“BBB”); }  public static void main(String[] args) {  new Thread(new MyThread()).start();  }  }   What is the result?()  

  • A、 AAA
  • B、 BBB
  • C、 Compilation fails.
  • D、 The code runs with no output.

正确答案:A

第2题:

public class Foo {   public void main (String args) {   system.out.printIn(“Hello World.”);   }   }   What is the result? () 

  • A、 An exception is thrown.
  • B、 The code does no compile.
  • C、 “Hello World.” Is printed to the terminal.
  • D、 The program exits without printing anything.

正确答案:A

第3题:

Given:What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?()

A. It is true that j==i.

B. It is false that j==i.

C. An exception is thrown at runtime.

D. Compilation fails because of an error in line 13.


参考答案:D

第4题:

String foo = “blue”;    Booleanbar = new Boolean [1];    if (bar[0]) {    foo = “green”;    }   What is the result?()  

  • A、 Foo has the value of “”
  • B、 Foo has the value of null.
  • C、 Foo has the value of “blue”
  • D、 Foo has the value of “green”
  • E、 An exception is thrown.
  • F、 The code will not compile.

正确答案:F

第5题:

Which of the following best describes what is meant by Linux Affinity on AIX?()

  • A、The ability to install a Linux system on an AIX system
  • B、The ability to install an AIX system on a Linux system
  • C、The ability to compile and run a Linux application on AIX
  • D、The ability to compile and run an AIX application on Linux

正确答案:C

第6题:

What will be the result of attempting to run the following program?()   public class Qaa75 {   public static void main(String args[]) {   String[][][] arr = {   { {}, null },   { { "1", "2" }, { "1", null, "3" } },   {},   { { "1", null } }  };   System.out.println(arr.length + arr[1][2].length);   }   }  

  • A、The program will terminate with an ArrayIndexOutOfBoundsException.
  • B、The program will terminate with a NullPointerException.
  • C、4 will be written to standard output.
  • D、6 will be written to standard output.
  • E、7 will be written to standard output.

正确答案:A

第7题:

What will be the result of attempting to compile and run the following code?()   public class Q6b0c {   public static void main(String args[]) {  int i = 4;  float f = 4.3;   double d = 1.8;   int c = 0;   if (i == f) c++;   if (((int) (f + d)) == ((int) f + (int) d))  c += 2;   System.out.println(c);   }   }  

  • A、The code will fail to compile.
  • B、0 will be written to the standard output.
  • C、1 will be written to the standard output.
  • D、2 will be written to the standard output.
  • E、3 will be written to the standard output.

正确答案:A

第8题:

public class foo {   public static void main (Stringargs) {  String s;   system.out.printIn (“s=” + s);   }   }   What is the result?()

  • A、 The code compiles and “s=” is printed.
  • B、 The code compiles and “s=null” is printed.
  • C、 The code does not compile because string s is not initialized.
  • D、 The code does not compile because string s cannot be referenced.
  • E、 The code compiles, but a NullPointerException is thrown when toString is called.

正确答案:C

第9题:

What will be the result of attempting to compile and run the following program?()   public class Q28fd {   public static void main(String args[]) {   int counter = 0;   l1:   for (int i=10; i<0; i--) {   l2:  int j = 0;   while (j < 10) {   if (j > i) break l2;   if (i == j) {   counter++;   continue l1;   }   }   counter--;   }   System.out.println(counter);  }   }   

  • A、The program will fail to compile.
  • B、The program will not terminate normally.
  • C、The program will write 10 to the standard output.
  • D、The program will write 0 to the standard output.
  • E、The program will write 9 to the standard output.

正确答案:A

第10题:

int index = 1;  String [] test = new String[3];  String foo = test[index];     What is the result?()  

  • A、 Foo has the value “”
  • B、 Foo has the value null
  • C、 An exception is thrown
  • D、 The code will not compile

正确答案:B

更多相关问题