下面程序段的执行结果是( )public class Foo {public static void main(String[] args) {try{return;}finally{System.out.println("Finally");}}}
A. 编译能通过,但运行时会出现一个例外
B. 程序正常运行,并输出“Finally”
C. 程序正常运行,但不输出任何结果
D. 因为没有catch语句块,所以不能通过编译
查看答案
能单独和finally语句一起使用的块是( )。
A. try
B. catch
C. throw
D. throws
下面程序的执行结果是( )。public class Test {public static void main(String[] args) {new Test().test();}public void test(){try{System.out.print("try");}catch(ArrayIndexOutOfBoundsException e){System.out.print("catch1");}catch(Exception e){System.out.print("catch2");}finally{System.out.println("finally");}}}
A. try finally
B. try catch1 finally
C. try catch2 finally
D. finally
下面程序抛出的RuntimeException异常是( )。public static void main(String[] args) {System.out.println(1/0);}}
A. NumberFormatException
B. Exception
C. ArrayIndexOutOfBoundsException
D. ArithmeticException
下列类中在多重catch中同时使用时,( )异常类应该最后列出。
A. NumberFormatException
B. Exception
C. ArrayIndexOutOfBoundsException
D. ArithmeticException