欢迎来到天天文库
浏览记录
ID:62033607
大小:140.00 KB
页数:2页
时间:2021-04-15
《Java面向对象程序设计习题 (10).doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第十章异常处理[习题]1.什么叫异常?列出5个异常的例子。2.Java的异常处理块的形式是什么样?3。Java中,关键字try、catch、finnally、throw和throws,各有何作用?4.如下代码输出结果是什么?为什么?publicclass test{ publicstatic void main(Stringargs[]){ int i=1, j=1; try{ i++; j——; if(i/j〉 1) i++; } catch(ArithmeticExceptione) { System.out.println(0); } catc
2、h(ArrayIndexOutOfBoundsExceptione) { System。out.println(1); } catch(Exceptione){ System.out。println(2); } finally{ System.out.println(3); } System。out.println(4); }}5.从键盘输入两个数,进行相加,显示和。当输入串中含有非数字时,通过异常处理机制,使程序能正确运行。6.编写一个程序完成:完成在银行的取款和存款操作。在定义银行类时,若取款数大于余额则作为异常处理。
此文档下载收益归作者所有