首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序输出的结果是什么? ( ) public class Quiz2 { public static void main(String args[]) { try {throw new My
下面程序输出的结果是什么? ( ) public class Quiz2 { public static void main(String args[]) { try {throw new My
admin
2010-07-28
33
问题
下面程序输出的结果是什么? ( ) public class Quiz2 { public static void main(String args[]) { try {throw new MyException(); }catch(Exception e) { System.out.println("It’s caught!"); }finally{ System.out.println("It’s finally caught!"); } } } class MyExeeption extends Exception{}
选项
A、It’s finally caught!
B、It’s caught!
C、It’s caught!/It’sfinally caught!
D、无输出
答案
4
解析
本题是对异常处理基本知识的考查。本程序中创建了一个异常类MyExce-ption,它的祖先类是Exception。在程序中,程序先发出异常MyException,下面是catch捕获异常,但是catch列表中并没有与之对应的MyException,但是有一个Exception,它是MyException的祖先类。如果有多种异常需要捕获,在安排catch语句的顺序时要注意,应该首先捕获最特殊的类,然后逐渐一般化。 例如,IOException类是 FileNotFoundException类的父类,就应该首先捕获FileNotFoundException异常,然后捕获IOException异常。所以运行结果是Ifs caught!/It’s finally caught!
转载请注明原文地址:https://kaotiyun.com/show/Zh9p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
在软件测试设计中,软件测试的主要目的是
软件开发环境是全面支持软件开发全过程的____________集合。
下列叙述中正确的是
下列属于白盒测试方法的是()。
有三个关系R、S和T如下:则由关系R和S得到关系T的操作是()。
数据库设计中反映用户对数据要求的模式是
获得用户输入的一个字符串,输出每个字符对应的UniCode值,这些值一行输出,采用逗号分隔,最后没有逗号。请完善代码。s=input(’’请输入一个字符串:’’)ls=[]forcins:①print(②)
考生文件夹下存在一个文件PY202.py,该文件是本题目的代码提示框架,其中代码可以任意修改。请在该文件中编写代码,以实现如下功能:键盘输入一组水果名称并以空格分隔,共一行,示例格式如下:苹果芒果草莓芒果苹果草莓芒果香蕉
下列接口中,继承了Collection接口的是______。
随机试题
Listentothefollowingpassage.Altogetherthepassagewillbereadtoyoufourtimes.Duringthefirstreading,whichwillbe
哪种疾病的病原体不能从患者粪便中排出
TIA发作,症状一般持续多长时间
患儿6岁,生长发育落后,曾经多次患肺炎,平时无发绀。听诊于胸骨左缘上方闻及一连续性“机器”样杂音,伴水冲脉、指甲床毛细血管波动。该患儿的血流动力学改变主要为
在Word编辑状态下,通过()可以选中整个文档内容。
某公司正着手编制2011年5月的现金预算。有关资料为:(1)2011年2—4月份的产品销售收入分别为300000元、320000元和350000元,预计5月份的销售收入为400000元,估计的收款情况为:当月收款50%,次月收款30%,再次月收款20%。
未成年人享有生存权、发展权、受保护权、参与权等权利,国家根据未成年人身心发展特点给予()保护,保障未成年人的合法权益不受侵犯。
电子现金,又称数字现金,是现金的电子化。它的主要特点是(36)。
Whatarethespeakersmainlydiscussing?
A、Gobacktothemodelingagency.B、Gobackhome.C、Holdupaconference.D、Goaroundthecompany.D
最新回复
(
0
)