请阅读下列程序代码,然后将程序的执行结果补充完整。横线处应填写的内容是( )。程序代码: public class throws Exception{ static void Proc(i ntsel) throws Arithmetic Excepti

admin2012-12-02  55

问题 请阅读下列程序代码,然后将程序的执行结果补充完整。横线处应填写的内容是(  )。程序代码:
public class throws Exception{
static void Proc(i ntsel)
throws Arithmetic Exception ,Array Index Out Of
Bounds Exception{
Syste m.out .pri ntln("InSituation"+sel);
if(sel ==0){
Syste m.out .pri ntln("noException caught");
return ;

else if(sel ==1){
i nt i Array[]=ne wi nt[4];
i Array[1]=3;


public static void mai n(Stri ng args[]){
try{
Proc(0);
Proc(1);

catch(Array Index Out Of Bounds Exception e){
Syste m.out .pri ntln("Catch"+e);

fi nally{
Syste m.out .pri ntln("i nProcfi nally");



执行结果:
In Situation 0
no Exception caught
i n Proc fi nally

选项 A、In Situation 1
B、In Situation
C、with Catch
D、i nt i Array 1

答案A

解析 本题考查考生阅读Java 程序的能力。题目程序看似复杂,但流程非常简单。程序的public 类是throws Exception ,类中定义了Proc(i ntsel)方法。程序入口是mai n()方法,使用try -catch -fi nally 来捕获ArithmeticException 和Array IndexOut OfBounds Exception 异常,这两个异常是关于算术异常或数组索引越界的异常。执行Proc(0)时,输出In Situation0和no Exception caught 两条信息;执行Proc(1)时,输出In Situation1和i n Proc fi nally 两条信息。整个程序并未发生异常。
转载请注明原文地址:https://kaotiyun.com/show/nBID777K
0

相关试题推荐
最新回复(0)