首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请阅读下列程序代码,然后将程序的执行结果补充完整。 程序代码: public class throwsException{ static void Proc(int sel) throws ArithmeticException,ArrayInde
请阅读下列程序代码,然后将程序的执行结果补充完整。 程序代码: public class throwsException{ static void Proc(int sel) throws ArithmeticException,ArrayInde
admin
2009-02-10
38
问题
请阅读下列程序代码,然后将程序的执行结果补充完整。
程序代码:
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
选项
答案
InSituationl
解析
本题考查考生阅读Java程序的能力。题目程序看似复杂,但流程非常简单。程序的public类是throwsException,类中定义了Proc(intsel)方法。程序入口是main()方法,使用try-catch-finally来捕获ArithmeticException和ArrayIndexOutOfBounds- Exception异常,这两个异常是关于算术异常或数组索引越界的异常。执行Proc(0)时,输出In Situation 0 和no Exception caught两条信息;执行Proc(1)时,输出In Situationl和in Proc finally两条信息。整个程序并未发生异常。
转载请注明原文地址:https://kaotiyun.com/show/iJnp777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
检查软件产品是否符合需求定义的过程称为()。
在VisualFoxPro中,在数据库中创建表的CREATETABLE命令中定义主索引、实现实体完整性规则的短语是()。
在考生文件夹下,有一个学生数据库sdb,打开该数据库,完成如下操作:(1)为学生表student的“性别”字段增加约束:性别“男女”,出错提示信息为“性别必须是男或女”,默认值为“女”。(2)为学生表student创建一个主索引,主索引的索引名为sid
在考生文件夹下完成下列操作:(1)使用SQL命令根据“教师”表产生一个结构和数据完全一致的“高校教师”表,并按职工号递增排序。(2)使用报表向导为“教师”表创建一个名为two的报表,选择“教师”表的所有字段,按“职工号”降序排列,标题为“教师情况报表”
在考生文件夹下,打开资源数据库frdb,完成如下简单应用:(1)使用表单向导选择资源表fr_t生成一个名为fr_edit的表单。要求选择fr_t表中所有字段,样式为阴影式;按钮类型为图片按钮;排序字段选择户主编号(升序);表单标题为“资源数据输入维护”。
为当前表中所有学生的总分增加10分,可以使用的命令是
下列对于线性链表的描述中正确的是
层次型、网状型和关系型数据库划分原则是
数据库应用系统中的核心问题是()。
在Java中,所有类的根类是()。
随机试题
桩冠修复时理想的冠桩直径应为根径的
主要通过呼吸道传播的细菌是
根据《商业银行资本管理办法(试行)》的规定交易账户中的金融工具和商品头寸原则上还应满足的条件不包括()。
关于“敬业”,正确的说法是()。
【2017上】简述班主任培养班集体的主要方法。
表现在人对现实的态度和相应的行为方式中的比较稳定的、具有核心意义的个性心理特征是()
国家副主席习近平在全国科技工作会议上指出:科学研究一定要同落实科学发展观相结其原因在于()。
下面哪项陈述可以从上表中得出?()Ⅰ.机车生产在2004年上半年增长率低甚至处于负增长态势Ⅱ.民用钢质船舶、发电设备在2004年呈成倍增长态势,反映出全国煤电油运紧张Ⅲ.冶炼设备在2004年度,前期增幅高,后期猛跌
在下面关于微处理器的叙述中,不正确的是( )。
Itwastheworsttragedyin【C1】______history,sixtimesmoredeadlythantheTitanic.WhentheGermancruiseshipWilhelmGu
最新回复
(
0
)