题目内容

在Java 中,假定有一个包含引起异常(不是一个RuntimeException)的代码的方法,用( )方式告诉方法的调用者要捕获该异常

A. throw Exception
B. throws Exception
C. new Exception
D. 不用特别指定

查看答案
更多问题

考虑下列JAVA代码:class A{public static void main(String[ ] args){try{System.out.println("Hello,World!");}}}这段代码错误的原因是( )。

A. 没有catch和finally块
B. 没有抛出异常的代码不能出现在try代码块内
C. 如果没有catch块而使用try,main( )会总是抛出异常
D. class A没有throws IOException

分析下面代码:public class testException{public static void main(String[ ] args){int a[ ]={0,1,2,3,4};int sum=0;try{for(int i=1;i<6;i++)sum=sum+a[i];System.out.println("sum=" + sum);}catch(ArrayIndexOutOfBoundsException e){System.out.println("数组越界");}finally{System.out.println("程序结束");}}}输出结果将是( )。

A. 10数组越界程序结束
B. 10程序结束
C. 数组越界程序结束
D. 程序结束

自定义异常类时,可以继承的类是( )。

A. Error
B. Applet
C. Exception及其子类
D. AssertionError

电路中各点的电位的高低与绕行方向无关

A. 对
B. 错

答案查题题库