A-A+

阅读下列程序片段。 Public void test{ Try{ sayHello; sys

2022-08-05 21:12:30 问答库 阅读 172 次

问题详情

阅读下列程序片段。 Public void test{ Try{ sayHello; system.out.println("hello"): }catch(ArraylndexOutOfBoundException e){ System.out.println("ArraylndexOutOfBoundExcep— tion"); }catch(Exception e){ System.out.println("Exception"): }finally{ System.Out.println("finally"); } } 如果sayHello方法正常运行,则test方法的运行结果将是()。
A.Hello
B.ArraylndexOutOfBondsException
C.Exception Finally
D.Hello Finally请帮忙给出正确答案和分析,谢谢!

参考答案

正确答案:D
D。【解析】sayHello方法正常运行则程序不抛出异常,并执行finally,所以为D。

考点:片段,程序