请阅读下列程序代码 然后将程序的执行结果补充完整。 程序代码: public class throw

大学专科 已帮助: 时间:2023-07-28 04:47:29

请阅读下列程序代码,然后将程序的执行结果补充完整。 程序代码: 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
请帮忙给出正确答案和分析,谢谢!

难度:⭐⭐⭐

题库:大学专科,电子信息,计算机类

标签:正确答案,程序代码,结果

参考解答

用户头像

435***273

2023-07-28 04:47:29

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

上一篇 下列程序创建了一个线程并运行 请填空 使程序完整。 public class ThreadTest{

下一篇 每个Applet程序必须有一个类是【 】类的子类。请帮忙给出正确答案和分析 谢谢!

相似问题