首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序输出的结果是什么? ( ) 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
2012-12-13
13
问题
下面程序输出的结果是什么? ( ) 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 MyException extends Exception{}
选项
A、It’s finally caught!
B、It’s caught!
C、It’s caught!/It’s finally caught!
D、无输出
答案
4
解析
本题是对异常处理基本知识的考查。本程序中创建了一个异常类MyExce ption,它的祖先类是Exception。在程序中,程序先发出异常MyException,下面是catch捕获异常,但是catch列表中并没有与之对应的MyExcepfion,但是有一个Exception,它是MyException的祖先类。如果有多种异常需要捕获,在安排catch语句的顺序时要注意,应该首先捕获最特殊的类,然后逐渐一般化。例如,IOExcepfion类是 FileNotFoundException类的父类;就应该首先捕获FileNotFoundException异常,然后捕获IOExcepfion异常。所以运行结果是It’s caught!/It’s finally caught!
转载请注明原文地址:https://kaotiyun.com/show/iF2p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
关于数据组织的维度描述正确的是()。
现在假设有一个包含一个函数的程序放在一个文件中,在主程序文件中使用下面各种方法来导入它,哪一种方法是错误的?()
设有表示学生选课的3张表,学生S(学号,姓名,性别,年龄,身份证号),课程C(课号,课名),选课SC(学号,课号,成绩),则表SC的关键字(键或码)为()。
学校的每个社团都有一名团长,且一个同学可同时担任多个社团的团长,则实体团长和实体社团间的联系是()。
下面关于对象和类的关系描述错误的是()。
下面哪一项不属于面向对象的特点()。
有两个关系R和T如下所示: 则由关系R得到关系T的运算是()。
线程模型在Java中是由【】类进行定义和描述的。
下列哪个方法是用来专门定义临界区,实现线程的同步?
软件开发的结构化设计(SD)方法,全面指导模块划分的最重要原则应该()
随机试题
财政支出边际倾向的计算公式为()
患儿,1岁。发热,流涕,咳嗽3天就诊,体温39.5℃,耳后发际处可见红色斑疹,疹间皮肤正常,流泪,结膜充血。有价值的检查是
小唾液腺的多形性腺瘤好发于
英译汉:“Moscow”,正确的翻译为( )。
只要一国的国际收支平衡表是平衡的,该国的国际收支就是平衡的。()
企业将自己的储蓄转化为投资的融资方式属于()。
在我国,证券公司在业务上必须接受()的领导、管理、监督和协调。
A、 B、 C、 BTwomilesfromhereanswerswhere.Choice(A)answerswhendoyouplaygolf.Choice(C)confuses
TheagingofsocietyinJapanforeshadowschallengesaheadforotheradvancedindustrialnationsliketheUnitedStates.About2
I______myteachertowriteareferencelettertoirieifIseeher.
最新回复
(
0
)