当前位置:IT认证>软件水平

问题:[填空题]

[填空题] 请阅读下列程序代码,然后将程序的执行结果补充完整。 程序代码: 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 ca

  

参考答案:

InSituationl

  参考解析

本题考查考生阅读Java程序的能力。题目程序看似复杂,但流程非常简单。程序的public类是throwsExeeption,类中定义了Proc(intsel)方法。程序入口是main()方法,使用try-catch-finally来捕获ArithmeticException和ArrayIndexOtaOfBounds-Exception异常,这两个异常是关于算术异常或数组索引越界的异常。执行Proc(0)时,输出InSituation0和noExceptioncaught两条信息;执行Proc(1)时,输出InSituationl和inProcfinally两条信息。整个程序并未发生异常。

微信端