题目内容

对于已经被定义过可能抛出异常的语句,在编程时()。

A. 使用try/catch语句处理异常,或用throws将其抛出
B. 如果程序错误,必须使用try/catch语句处理异常
C. 可以置之不理
D. 只能使用try/catch语句处理

查看答案
更多问题

下面程序段的执行结果是( )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

答案查题题库