单选题System.out.println(Math.sqrt(-4D));  What is the result?()A–2BNaNCInfinityDCompilation fails.EAn exception is thrown at runtime.

题目
单选题
System.out.println(Math.sqrt(-4D));  What is the result?()
A

 –2

B

 NaN

C

 Infinity

D

 Compilation fails.

E

 An exception is thrown at runtime.


相似考题
参考答案和解析
正确答案: C
解析: 暂无解析
更多“System.out.println(Math.sqrt(-4D));  What is the result?()  ”相关问题
  • 第1题:

    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

  • 第2题:

    Given:   11. String test = "This is a test";   12. String[] tokens = test.split("/s");   13. System.out.println(tokens.length);   What is the result?()

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

    正确答案: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题:

    try {  if ((new Object))(.equals((new Object()))) {  System.out.println(“equal”);  }else{  System.out.println(“not equal”);  }  }catch (Exception e) {  System.out.println(“exception”);  }   What is the result? () 

    • A、 equal
    • B、 not equal
    • C、 exception
    • D、 Compilation fails.

    正确答案:D

  • 第5题:

    System.out.println(Math.sqrt(-4D));  What is the result?()  

    • A、 –2
    • B、 NaN
    • C、 Infinity
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:B

  • 第6题:

    单选题
    public class Test {  public static void aMethod() throws Exception {  try {  throw new Exception(); } finally {  System.out.println(“finally”);  }  }  public static void main(String args[]) {  try {  aMethod();  } catch (Exception e) {  System.out.println(“exception”);  }  System.out.println(“finished”);  }  }  What is the result?()
    A

     finally

    B

     exception finished

    C

     finally exception finished

    D

     Compilation fails.


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

  • 第7题:

    单选题
    boolean bool = true; if(bool = false) { System.out.println(“a”); } else if (bool) { System.out.println(“c”); } else if (!bool) { System.out.println(“c”); } else { System.out.println(“d”); } What is the result?()
    A

     a

    B

     b

    C

     c

    D

     d

    E

     Compilation fails.


    正确答案: E
    解析: First of all, the second println statement should print the character ‘b’ instead of ‘c’. Also, the answer is not E. but C. Indeed, the following line is perfectly legal: if ‘(bool = false)’. The bool variable will simply take the value of false and the IF statement will be evaluated to false. Therefore, the correct answer is C. 

  • 第8题:

    单选题
    for (int i =0; 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.


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

  • 第9题:

    单选题
    public static void main(String[] args) {  try {  args=null;  args[0] = “test”;  System.out.println(args[0]);  } catch (Exception ex) {  System.out.println(”Exception”);  } catch (NullPointerException npe) {  System.out.println(”NullPointerException”);  }  }  What is the result?()
    A

     test

    B

     Exception

    C

     Compilation fails.

    D

     NullPointerException


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

  • 第10题:

    单选题
    try {  int x = 0;  int y = 5 / x;  } catch (Exception e) {  System.out.println(“Exception”);  } catch (ArithmeticException ae) {  System.out.println(“Arithmetic Exception”);  }  System.out.println(“finished”);  What is the result?()
    A

     finished

    B

     Exception

    C

     Compilation fails.

    D

     Arithmetic Exception


    正确答案: A
    解析: The correct answer to this question is D. When an int value is divided by zero, a runtime exception occurs. There are no compilation errors. 

  • 第11题:

    单选题
    try {  if ((new Object))(.equals((new Object()))) {  System.out.println(“equal”);  }else{  System.out.println(“not equal”);  }  }catch (Exception e) {  System.out.println(“exception”);  }   What is the result? ()
    A

     equal

    B

     not equal

    C

     exception

    D

     Compilation fails.


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

  • 第12题:

    单选题
    Given:   11. String test = "This is a test";   12. String[] tokens = test.split("/s");   13. System.out.println(tokens.length);   What is the result?()
    A

     An exception is thrown at runtime.

    B

     1

    C

     4

    D

     Compilation fails.

    E

     0


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

  • 第13题:

    public static void main(String[] args) {  String str = “null‟;  if (str == null) {  System.out.println(”null”);  } else (str.length() == 0) {  System.out.println(”zero”);  } else {  System.out.println(”some”);  }  }  What is the result?()

    • A、 null
    • B、 zero
    • C、 some
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:D

  • 第14题:

    boolean bool = true; if(bool = false) { System.out.println(“a”); } else if (bool) { System.out.println(“c”); } else if (!bool) { System.out.println(“c”); } else { System.out.println(“d”); } What is the result?()  

    • A、 a
    • B、 b
    • C、 c
    • D、 d
    • E、 Compilation fails.

    正确答案:C

  • 第15题:

    public class Test {  public static void aMethod() throws Exception {  try {  throw new Exception(); } finally {  System.out.println(“finally”);  }  }  public static void main(String args[]) {  try {  aMethod();  } catch (Exception e) {  System.out.println(“exception”);  }  System.out.println(“finished”);  }  }  What is the result?()  

    • A、 finally
    • B、 exception finished
    • C、 finally exception finished
    • D、 Compilation fails.

    正确答案:C

  • 第16题:

    public void testIfA(){ if(testIfB("True")){ System.out.println("True"); }else{ System.out.println("Nottrue"); } } public Boolean testIfB(Stringstr){ return Boolean.valueOf(str); } What is the result when method testIfA is invoked?()

    • A、True
    • B、Nottrue
    • C、Anexceptionisthrownatruntime.
    • D、Compilationfailsbecauseofanerroratline12.
    • E、Compilationfailsbecauseofanerroratline19.

    正确答案:A

  • 第17题:

    String a = null;  a.concat(“abc”);  a.concat(“def”);  System.out.println(a);   What is the result?()  

    • A、 abc
    • B、 null
    • C、 abcdef
    • D、 Compilation fails.
    • E、 The code runs with no output.
    • F、 An exception is thrown at runtime.

    正确答案:F

  • 第18题:

    单选题
    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
    解析: 暂无解析

  • 第19题:

    单选题
    int i = 1,j = 10;  do {  if(i>j) {  break;  } j--;  } while (++i <5);  System.out.println(“i =” +i+” and j = “+j); What is the result?()
    A

     i = 6 and j = 5

    B

     i = 5 and j = 5

    C

     i = 6 and j = 4

    D

     i = 5 and j = 6

    E

     i = 6 and j = 6


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

  • 第20题:

    单选题
    public void testIfA(){ if(testIfB("True")){ System.out.println("True"); }else{ System.out.println("Nottrue"); } } public Boolean testIfB(Stringstr){ return Boolean.valueOf(str); } What is the result when method testIfA is invoked?()
    A

    True

    B

    Nottrue

    C

    Anexceptionisthrownatruntime.

    D

    Compilationfailsbecauseofanerroratline12.

    E

    Compilationfailsbecauseofanerroratline19.


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

  • 第21题:

    单选题
    public static void main(String[] args) {  String str = “null‟;  if (str == null) {  System.out.println(”null”);  } else (str.length() == 0) {  System.out.println(”zero”);  } else {  System.out.println(”some”);  }  }  What is the result?()
    A

     null

    B

     zero

    C

     some

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


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

  • 第22题:

    单选题
    System.out.println(Math.sqrt(-4D));  What is the result?()
    A

     –2

    B

     NaN

    C

     Infinity

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


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

  • 第23题:

    单选题
    public static void main(String[]args){ String str="null"; if(str==null){ System.out.println("null"); }else(str.length()==0){ System.out.println("zero"); }else{ System.out.println("some"); } } What is the result?()
    A

    null

    B

    zero

    C

    some

    D

    Compilationfails.

    E

    Anexceptionisthrownatruntime.


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

  • 第24题:

    单选题
    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
    解析: 暂无解析