单选题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 TrueB NottrueC Ane

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

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

第1题:

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

第2题:

Given:What is the result when method testIfA is invoked?()

A.True

B.Not true

C.An exception is thrown at runtime.

D.Compilation fails because of an error at line 12.

E.Compilation fails because of an error at line 19.


参考答案:A

第3题:

下面程序执行后,输出的结果是( )。 public class Test { public static void main (String[] )args) { boolean m=true; if(m==false) System.out.println("假"); else if(m====true) System.out.println("真"); else System.out.println ("错误"); } }

A.真

B.假

C.错误

D.编译出错


正确答案:A
解析:这是一个if-else结构的程序,判断条件是布尔变量m是否为真,若为真则打印“真”,若为假则打印“假”,其他情况下打印“错误”。

第4题:

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

第5题:

public static void parse(String str) {  try {  float f= Float.parseFloat(str);  } catch (NumberFormatException nfe) {  f= 0;  } finally {  System.out.println(f);  }  }  public static void main(String[] args) {  parse(”invalid”);  }  What is the result?() 

  • A、 0.0
  • B、 Compilation fails.
  • C、 A ParseException is thrown by the parse method at runtime.
  • D、 A NumberFormatException is thrown by the parse method at runtime.

正确答案:B

第6题:

11.publicvoidtestIfA(){12.if(testIfB(”True”)){13.System.out.println(”True”);14.}else{15.System.out.println(”Nottrue”);16.}17.}18.publicBooleantestIfB(Stringstr){19.returnBoolean.valueOf(str);20.}WhatistheresultwhenmethodtestIfAisinvoked?()

A.True

B.Nottrue

C.Anexceptionisthrownatruntime.

D.Compilationfailsbecauseofanerroratline12.

E.Compilationfailsbecauseofanerroratline19.


参考答案:A

第7题:

public void foo( boolean a, boolean b ){  if( a ) {  System.out.println( “A” );  } else if ( a && b ) {  System.out.println( “A&&B” );  } else { 17. if ( !b ) {  System.out.println( “notB” );  } else {  System.out.println( “ELSE” );  }  } }  What is correct?()  

  • A、 If a is true and b is true then the output is “A&&B”.
  • B、 If a is true and b is false then the output is “notB”.
  • C、 If a is false and b is true then the output is “ELSE”.
  • D、 If a is false and b is false then the output is “ELSE”.

正确答案:C

第8题:

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.


参考答案:D

第9题:

public class Test {  public static void main(String [] args) {  boolean assert = true;  if(assert) {  System.out.println(”assert is true”);  }  }  } Given:  javac -source 1.3 Test.java  What is the result?() 

  • A、 Compilation fails.
  • B、 Compilation succeeds with errors.
  • C、 Compilation succeeds with warnings.
  • D、 Compilation succeeds without warnings or errors.

正确答案:C

第10题:

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

更多相关问题