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?()
Amove the line 12 print statement into the foo() method
Bchange line 7 to public synchronized void go(){
Cchange the variable declaration on line 2 to private volatile int x;
Dwrap the code inside the foo() method with a synchronized(this) block
Ewrap 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?()
AYen returns correct values.
BEuro returns correct values.
CAn exception is thrown at runtime.
DYen and Euro both return correct values.
ECompilation fails because of an error at line 25.
FCompilation fails because of an error at line 30.