单项选择题
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. -
单项选择题
public static void main(String[] args) { try { args=null; args[0] = “test”; System.out.println(args[0]); } catch (Exception ex) { System.out.println(”Exception”); } catch (NullPointerException npe) { System.out.println(”NullPointerException”); } } What is the result?()
A. test
B. Exception
C. Compilation fails.
D. NullPointerException
