首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请阅读下列程序代码,然后将程序的执行结果补充完整。横线处应填写的内容是( )。程序代码: public class throws Exception{ static void Proc(i ntsel) throws Arithmetic Excepti
请阅读下列程序代码,然后将程序的执行结果补充完整。横线处应填写的内容是( )。程序代码: public class throws Exception{ static void Proc(i ntsel) throws Arithmetic Excepti
admin
2012-12-02
61
问题
请阅读下列程序代码,然后将程序的执行结果补充完整。横线处应填写的内容是( )。程序代码:
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://jikaoti.com/ti/bXkiFFFM
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
下列关于能源的叙述,正确的是()。
关于我国夏季气温分布的正确叙述是()。
若x、y、z是三个连续的负整数,并且x>y>z,则下列表达式中属于正奇数的是:
分布式数据库的【13】透明性是最高级别的透明性,它使得在编写程序时用户只需要对全局关系进行操作,这样简化了应用程序的维护。
下列程序中,给出两个整数2和3,分别求2除以3和2乘以3的结果,要求调用类ex1_1的方法method()来输出相应的结果,请将程序补充完整。程序运行结果如下:0.66666666666666666publicclassex1_
下列程序的输出结果是()。publicclassArrayTest{publicstaticvoidmain(Stringargs[]){int[]intArray=newint[3]for(int
下列能够正确创建线程的方法是()。①继承java.lang.Thread类,并重写run()方法②继承java.lang.Runnable类,并重写start()方法③实现java.lang.Thread接口,并实现run()方法④实现java
以下标识符不是关键字的是()。
随机试题
药材新的药用部位属于中药注册分类中的
脊髓损伤患者为了应用轮椅、拐杖或助行器,重点训练的肌肉是
增加金瓷结合的方法,除外A.喷砂B.除气C.超声波清洗D.电解E.预氧化
初产妇,足月顺产,产后发热38℃,经抗生素治疗后退热,产后2周恶露干净。现产后1个月,突然大量阴道出血,血压100/70mmHg,无其他不适。选择下列哪项处理最佳
反映肾小管重吸收功能的是
已知某.工艺性空调房间尺寸为6.0m×6.0m×4.Om。采用全面孔板送风,房间送风量为3500m3/h,孔口送风速度为4m/s,则稳压层的最小净高应为()。
工程项目工作定义的方法有哪些?
甲公司拥有乙公司80%的有表决权股份,能够控制乙公司财务和经营决策。2014年6月1日,甲公司将本公司生产的一批产品出售给乙公司,售价为1600万元,成本为1000万元。至2014年12月31日,乙公司已对外售出该批存货的40%,当日,剩余存货的可变现净值
下列各项中,不属于发行普通股股票的筹资特点的是()。
A、 B、 C、 D、 D在Internet中,路由器采用表驱动的路由选择算法,路由表中存储了可能的目的地址与如何到达目的地址的信息,从路由选择算法对网络拓扑和通信量变化的自适应能力的角度划分,可以分为静态路
最新回复
(
0
)