首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请阅读下列程序代码,然后将程序的执行结果补充完整。 程序代码: public class throwsException{ static void Proc(int sel) throws ArithmeticExcept
请阅读下列程序代码,然后将程序的执行结果补充完整。 程序代码: public class throwsException{ static void Proc(int sel) throws ArithmeticExcept
admin
2012-12-13
32
问题
请阅读下列程序代码,然后将程序的执行结果补充完整。
程序代码:
public class throwsException{
static void Proc(int sel)
throws ArithmeticException, ArrayIndexOutOfBoundsException
System.out.println("In Situation"+sel);
if(sel==0){
System.out.println("no Exception caught");
return;
}
else if(sel==1){
int iArray[]=new int[4];
iArray[1]=3;
}
}
public static void main(String args[]){
try{
Proc(0);
Proc(1);
}
catch (ArrayIndexOutOfBoundsException e){
System.out.println("Catch"+e);
}
finally{
System.out.println("in Proc finally");
}
}
}
执行结果
In Situation 0
no Exception caught
【 】
in Proc finally
选项
答案
In Situationl
解析
本题考查考生阅读Java程序的能力。题目程序看似复杂,但流程非常简单。程序的public类是throwsException,类中定义了Proc(int sel)方法。程序入口是main()方法,使用try-catch-fmally来捕获 ArithmeticException和ArrayIndexOutOfBounds Exception异常,这两个异常是关于算术异常或数组索引越界的异常。执行Proc(0)时,输出In Situation0和no Exception caught两条信息;执行Proc(1)时,输出In Situation1和in Proc finally两条信息。整个程序并未发生异常。
转载请注明原文地址:https://kaotiyun.com/show/vT2p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
考生文件夹下存在一个文件“PY202.py”’,请在该文件中作答,实现以下功能。输入某班各个同学就业的职业名称,职业名称之间用空格符间隔(按键结束输入)。完善Python代码,统计各职业就业的学生数量,按数量从大到小的顺序输出。例如输入:护士导游老师护士
下列关于Python缩进的描述中,错误的是()。
以下关于Python的return语句的描述中,正确的是()。
考生文件夹下存在一个文件“PY102.PY”.请写代码替换横线,不修改其他代码,实现以下功能。用键盘输入一段文本,保存在一个字符串变量s中,分别用Python内置函数和jieba库中已有函数计算字符串s的中文字符个数和中文词语个数。注意:中文字符包含中文
考生文件夹下存在两个Python源文件,分别对应两个问题,请按照文件内说明修改代码,实现以下功能。马和骆驼都是哺乳动物,它们都有4只脚,体型也差不多大.我们将在这里为它们编写属于它们各自的类。问题1:在“PY301-1.py”文件中修改
表格类型数据的组织维度最可能是()。
使用Python的函数,需要的步骤不包括()。
JApplet是顶层Swing容器,包括一个隐含的______。
当子类隐藏了父类的成员变量或重写了父类的方法时,若要访问父类的成员变量或调用父类的方法,在Java中是通过______来实现的。
源程序文档化要求程序加注释。注释一般分为序言性和【】。
随机试题
行政许可申请人隐瞒有关情况或者提供虚假材料申请行政许可的,行政机关不予受理或者不予行政许可,并给予警告;行政许可申请属于直接关系公共安全、人身健康、生命财产安全事项的,申请人在()内不得再次申请该行政许可。
软件过程是制作软件产品的一组活动及其结果。这些活动主要由软件人员来完成,软件活动主要包括软件描述、____①____、软件有效性验证和___②_____。其中,____③____定义了软件功能以及使用的限制。②
能反映类风湿关节炎病情活动性的实验室指标是
明代对药学发展贡献最大的本草著作是
建筑企业施工期间将其塔吊租赁给同一现场其他企业的收入应计入()。
有持有期为2天、置信号水平为98%的情况下,若所计算的风险价值为2万元,则表明该银行的资产组合()。
下列属于经济费用效益分析指标的有()。
现代学生观承认儿童是独立的人,尊重儿童的人格和权利。确立了()。
下列关于字段属性的叙述中,正确的是()。
A、Addsomepartstoherreport.B、Improveherwriting.C、Getherreportpublished.D、Rewriteherreport.B男士说如果女士想要发表报告的话,得修改其中几
最新回复
(
0
)