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

题目
单选题
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
解析: 暂无解析
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

int i = 1,j = 10;  do{  if (i>j) {  continue;  }  j--;  } while (++i <6);  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

正确答案:A

第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题:

下面程序段的输出结果是( )。 public class Test{ public static void main(String args[]){ int X,y; x=(int)Math.sqrt(5)/2+(int)Math.random*5/2; y=(int)Math.sqrt(3)/2+(int)Math.random*3/2; if(x>v) System.OUt.println("x>y"); elseif(x= =y) System.out.println("x=Y"); else System.out.println("x<y"): } }

A.x>y

B.x=Y

C.x<y

D.编译错误


正确答案:A
A。【解析】本题考查Java语言中if-else分支结构和几个标准函数语句的用法。本题中赋值号右边的两个表达式分别求两个标准函数的值,再进行整除,判断出x与y的大小。Math.sqrt计算一个数的平方根,Math.random输出[0,1)之间的随机数,本题中经过两条赋值语句后,x=1,y=0。进入分支结构后,满足if条件执行相应System.out.println("x>y");操作。

第4题:

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

第5题:

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

第6题:

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

第7题:

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

第8题:

System.out.println(Math.sqrt(-4D));Whatistheresult?()

A.–2

B.NaN

C.Infinity

D.Compilationfails.

E.Anexceptionisthrownatruntime.


参考答案:B

第9题:

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

第10题:

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

更多相关问题