单选题
Java
题号 #2242899
请阅读下列程序代码,然后将程序的执行结果补充完整。横线处应填写的内容是( )。
程序代码:
public class throwsExeeption{
static void Proc(intsel)
throws Arithmetic Exception,Array Index Out Of
Bounds Exception{
System.out.println("InSituation"+sel);
if(sel= =0){
System.OUt.println("noException caught");
return;
}
else if(sel= =l){
int iArray[]=newint[4];
iArray[1]=3;
}
}
public static void main(String args[]){
try{
Proe(O);
Proc(1);
}
catch(Array Index Out Of Bounds Exception e){
System.out.println("Catch"+e);
}
finally{
System.out.println("inProcfinally"):
}
}
}
执行结果:
In Situation 0
no Exception caught
in Proc finally
参考答案
A
答案解析
A。【解析】本题考查考生阅读Java程序的能力。题目程序看似复杂,但流程非常简单。程序的public类是thtowsExeeption,类中定义了Proe(intsel)方法。程序入口是main()方法,使用try-catch-finally来捕获ArithmeticExeeption和Array IndexOutOfBoundsExeeption异常,这两个异常是关于算术异常或数组索引越界的异常。执行Proe(0)时,输出In Situation0和no Exception caught两条信息;执行Proc(1)时,输出In Situationl和in Proc finally两条信息。整个程序并未发生异常。