题目内容

简述社区护理实施的5大要素

查看答案
更多问题

程序读入用户输入的一个值,要求创建一个自定义的异常,如果输入值大于10,使用throw语句显式地引发异常,异常输出信息为"something wrong!",语句为( )。

A. if (i>10) throw Exception("something wrong!");
B. if (i>10) throw Exception e ("something wrong!");
C. if (i>10) throw new Exception("something wrong!");
D. if (i>10) throw new Exception e ("something wrong!");

在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. 程序结束

答案查题题库