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


相似考题
更多“单选题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”相关问题
  • 第1题:

    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

  • 第2题:

    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

  • 第3题:

    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

  • 第4题:

    public class Alpha{  public static void main( string[] args ){  if ( args.length == 2 ) {  if ( args.[0].equalsIgnoreCase(“-b”) )  System.out.println( new Boolean( args[1] ));  }  }  }   And the code is invoked by using the command: java Alpha –b TRUE   What is the result?()  

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

    正确答案:A

  • 第5题:

    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

  • 第6题:

    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

  • 第7题:

    单选题
    public class Test {  public static void main(String [] args) {  System.out.println(args.length > 4 &&  args[4].equals(“-d”));  }  }   If the program is invoked using the command line: java Test One Two Three –d   What is the result?()
    A

     true

    B

     false

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: B
    解析: The correct answer to this question is D. The args[4] generates a runtime exception error because there are only 4 strings and the expression args[4] prints the 5th String but like it was said earlier, there are only 4 strings. 

  • 第8题:

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

  • 第9题:

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

  • 第10题:

    单选题
    public class Alpha{  public static void main( string[] args ){  if ( args.length == 2 ) {  if ( args.[0].equalsIgnoreCase(“-b”) )  System.out.println( new Boolean( args[1] ));  }  }  }   And the code is invoked by using the command: java Alpha –b TRUE   What is the result?()
    A

     true

    B

     null

    C

     false

    D

     Compilation fails.

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


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

  • 第11题:

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


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

  • 第12题:

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

  • 第13题:

    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

  • 第14题:

    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

  • 第15题:

    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

  • 第16题:

    11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  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

  • 第17题:

    public class SyncTest {  private int x;  private int y;  public synchronized void setX (int i) (x=1;)  public synchronized void setY (int i) (y=1;)  public synchronized void setXY(int 1)(set X(i); setY(i);)  public synchronized Boolean check() (return x !=y;)  }  Under which conditions will check () return true when called from a different class?

    • A、 Check() can never return true.
    • B、 Check() can return true when setXY is called by multiple threads.
    • C、 Check() can return true when multiple threads call setX and setY separately.
    • D、 Check() can only return true if SyncTest is changed to allow x and y to be set separately.

    正确答案:A

  • 第18题:

    public class Test {  public static void main(String [] args) {  System.out.println(args.length > 4 &&  args[4].equals(“-d”));  }  }   If the program is invoked using the command line: java Test One Two Three –d   What is the result?()  

    • A、 true
    • B、 false
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:D

  • 第19题:

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

  • 第20题:

    单选题
    11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  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.


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

  • 第21题:

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


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

  • 第22题:

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


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

  • 第23题:

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

  • 第24题:

    单选题
    public class SyncTest {  private int x;   private int y;   public synchronized void setX (int i) (x=1;)   public synchronized void setY (int i) (y=1;)   public synchronized void setXY(int 1)(set X(i); setY(i);)   public synchronized Boolean check() (return x !=y;)   }   Under which conditions will check () return true when called from a different class?
    A

     Check() can never return true.

    B

     Check() can return true when setXY is called by multiple threads.

    C

     Check() can return true when multiple threads call setX and setY separately.

    D

     Check() can only return true if SyncTest is changed to allow x and y to be set separately.


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