首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请阅读下列程序代码,然后将程序的执行结果补充完整。 程序代码: public class throwsException{ static void Proc(int sel) throws ArithmeticExcept
请阅读下列程序代码,然后将程序的执行结果补充完整。 程序代码: public class throwsException{ static void Proc(int sel) throws ArithmeticExcept
admin
2012-12-13
71
问题
请阅读下列程序代码,然后将程序的执行结果补充完整。
程序代码:
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全国计算机二级
相关试题推荐
以下程序中,while循环的循环次数是()。i=0whilei<10:ifi<1:print("Python")continueifi==5:print("
以下程序的输出结果是()。deffun(x):try:returnx*4except:returnxprint(fun("5"))
在Python中,使用for-in-方式形成的循环不能遍历的类型是()。
下列哪个语句在Python中是非法的?()
下面属于“对象”成分之一的是()。
下面说法错误的是()。
Container是下列______类的子类。
Applet是—个______容器。
setLayout()方法是所有容器的父类______的方法。
在七类内聚中具有最强内聚的一类是()。
随机试题
下列关于中国古琴的说法中,正确的是()。
A.TATA盒B.GC盒C.CAAT盒D.CCAAT盒(2010年第132题)转录因子Spl的结合位点是
A.60°B.30°C.25°D.15°E.45°上颌窦癌两夹角50°照射时,楔形角应取
A.靠近抗原孔B.靠近抗体孔C.在两孔之间D.呈多条沉淀线E.不出现沉淀线双扩试验平板法中,若抗原含量较大,则反应沉淀线应
在估价中测算开发利润应掌握()。
教师讲课过程中的间隔和停顿是运用感知的()。
美国是一个移民国家,学校的学生来自不同的种族与家庭,通过接受系统的学校教育,学生掌握现代文化知识,建立独特的族群和阶层文化,社会也因此充满生机与活力。这主要体现了教育的()
刑法规定,故意杀人情节较轻的,处3年以上10年以下有期徒刑。对此追诉期限为()。
JohnaswellasJack______justbeenbackfromanimportantmeeting.
CareerBuilder.comnowoffersthemostfunctionalandeasy-to-useonlinejobsearchforScience&Biotechjobs.Infact,therea
最新回复
(
0
)