欢迎来到天天文库
浏览记录
ID:38719268
大小:38.50 KB
页数:5页
时间:2019-06-18
《练习10 Java异常处理练习题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Java异常处理练习题[]选择题:1.问:如下哪些异常类的定义是合法的?A:classMyExceptionimplmentsThrowable{}B:publicclassMyExceptionextendsException{}C:publicclassMyExceptionimplementsException{}D:publicclassMyExceptionextendsRuntimeException{}E:以上定义都不是答:2.问:下列哪些方法定义是合法的A:voida()throwExc
2、eption,IOException{}B:publicvoida()ThrowsIOException,Exception{}C:publicvoida()throwsException,Error{}D:publicvoida()ThrowString,Exception{}E:publicvoida()throwsObject,Exception{}F:以上定义都合法。答:3.给定代码:packagecom.ibm.oa.business;importjava.io.*;publicclassIn
3、fo{publicvoidshow()throwsIOException,SQLException{---------------------------------------}}问:在划线部分,如下哪个语句是合法的?A:throwsnewException;B:throwsnewException(“Error”);C:thrownewRemoteException(“Error”);E:throwsIOException(“Error”);F:thrownewBatchUpdateExceptio
4、n();G:以上定义都不合法。答:4.给定代码://类1定义packagecom.ibm.oa.business;importjava.io.*;publicclassInfo{publicvoidshow()throwsNullPointException,IOException{}}//类2定义packagecom.ibm.oa.client;importjava.io.*;publicclassNewsInfoextendsInfo{----------------------------{}}问
5、:在划线处,下列哪些语句是合法的?A:publicvoidshow()B:publicStringshow()throwsNullPointException,IOExceptionC:publicvoidshow()throwsIOExceptionD:publicvoidshow()throwsNullPointException,RuntimeExceptionE:publicvoidshow()throwsException,IOExceptionF:以上定义都不是。答5.给出代码://接口定义
6、1packageibm.com.oa.business;importjava.io.*;publicInterfaceInfo{voidshow()throwsIOException,RuntimeExcepton;}//实现类定义packagecom.ibm.oa.client;importjava.io.*;publicclassInfoImplimplementsInfo{---------------------------------------------{}}问:在划线处,写入如下哪些语句
7、是合法的?A:publicvoidshow()B:publicvoidshow()throwsExceptionC:publicvoidshow()throwsClassCastExceptonD:publicvoidshow()throwsIOExceptionE:publicvoidshow()throwsEOFException,NullPointExceptionF:以上定义都不合法答:6.问:下列哪些异常处理语句是合法的A:try{Connectioncn=DriverManager.getC
8、onnection(“aaa”);}catch(IOExceptione1){}catch(SQLExceptione2){}B:try{inti=10;i++;}catch(IOExceptione1){}catch(Exceptione2){}C:try{Connectioncn=DriverManager.getConnection(“aaa”);}catch(SQLExceptione1){}catch(Exceptione2){}
此文档下载收益归作者所有