单项选择题
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”);
相关考题
-
单项选择题
static void test() throws RuntimeException { try { System.out.print(”test “); throw new RuntimeException(); } catch (Exception ex) { System.out.print(”exception “); } } public static void main(String[] args) { try { test(); } catch (RuntimeException ex) { System.out.print(”runtime “); } System.out.print(”end “); } What is the result?()
A. test end
B. Compilation fails.
C. test runtime end
D. test exception end
E. A Throwable is thrown by main at runtime. -
单项选择题
static void test() { try { String x=null; System.out.print(x.toString() +“ “); } finally { System.out.print(“finally “); } } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } } What is the result?()
A. null
B. finally
C. null finally
D. Compilation fails.
E. finally exception -
单项选择题
static void test() throws Error { if (true) throw new AssertionError(); System.out.print(”test “); } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } System.out.print(”elld “); } What is the result?()
A. end
B. Compilation fails.
C. exception end
D. exception test end
E. A Throwable is thrown by main.
F. An Exception is thrown by main.
