易搜题 > 资格证大类 > 计算机编程 > 问题详情
问题详情

11. public void someMethod(Object value) {  12. // check for null value ....  20. System.out.println(value.getClass());  21. }  What, inserted at line 12, is the appropriate way to handle a null value?() 

A、 assert value == null;

B、 assert value !null, “value is null”;

C、 if (value == null) { throw new AssertionException(”value is null”);

D、 if (value == null) { throw new IllegalArgumentException(”value is null”);

未找到的试题在搜索页框底部可快速提交,在会员中心"提交的题"查看可解决状态。 收藏该题
查看答案

相关问题推荐

  • public class AssertStuff {  public static void main(String [] args) {  int x= 5;  int y= 7;  assert (x> y): “stuff”;  System.out.println(”passed”);  }  }  And these command line invocations:java AssertStuff java -ea AssertStuff What is the result?()

    A、 passed stuff

    B、 stuff passed

    C、 passed  An AssertionError is thrown with the word “stuff” added to the stack trace.

    D、 passed  An AssertionError is thrown without the word “stuff” added to the stack trace.

    E、 passed  An AssertionException is thrown with the word “stuff” added to the stack trace.

    F、 passed  An AssertionException is thrown without the word “stuff” added to the stack trace.

  • Which interface does java.util.Hashable implement?()  

    A、 Java.util.Map.

    B、 Java.util.List.

    C、 Java.util.Hashable.

    D、 Java.util.Collection.

  • Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5?()

    A

    move the line 12 print statement into the foo() method

    B

    change line 7 to public synchronized void go(){

    C

    change the variable declaration on line 2 to private volatile int x;

    D

    wrap the code inside the foo() method with a synchronized(this) block

    E

    wrap the for loop code inside the go() method with a synchronized block synchronized(this){//for loop code here}

  • 1. public class ArrayTest {  2. public static void main (String[]args)  {  3. float f1[], f2[];  4. f1 = new float [10];  5. f2 = f1;  6. System.out.printIn (“f2[0]=” + f2[0]);  7.  }  8. }   What is the result?()  

    A、 It prints f2[0] = 0.0

    B、 It prints f2[0] = NaN

    C、 An error at line 5 causes compile to fail.

    D、 An error at line 6 causes compile to fail.

    E、 An error at line 6 causes an exception at runtime.

  • Assume that country is set for each class.  Given:  10. public class Money {  11. private String country, name;  12. public getCountry() { return country; }  13.}  and:  24. class Yen extends Money {  25. public String getCountry() { return super.country; }  26. }  27.  28. class Euro extends Money {  29. public String getCountry(String timeZone) {  30. return super.getCountry();  31. }  32. }  Which two are correct?()

    A

     Yen returns correct values.

    B

     Euro returns correct values.

    C

     An exception is thrown at runtime.

    D

     Yen and Euro both return correct values.

    E

     Compilation fails because of an error at line 25.

    F

     Compilation fails because of an error at line 30.

联系客服 会员中心
TOP