第十二章
答:将检测错误于处理错误分开来了
答:
答: 加 会导致溢出 不会抛异常
答:!.当发生异常时,"#$# 在 %#%& 子句中搜索处理程序。因此,要在程序中捕获
异常,需要编写一个 '%#%& 语句,如下所示:
尝试(
)
%#%&( *%+*)(
)
答:,$##
-+#.&%#%&/%0
更换后:-+#.&%#%&/%0
答:1#23/2
答:425&6#/是所有异常类的跟。所有的 "#$# 异常类都直接或者间接地继承它。
答:7:8+ *%+9: *%+
StringIndexOutOfBoundsExceptio n classCastException
9: *%+Infinity
答:12.9 因为任何代码都可能发生系统错误和运行错误,在方法后面声明
Public void myMthod() throws Exception 可以声明多异常
答:12.10 必检异常就是编译器强制程序猿检查并通过 try——catch 来处的异常
RuntimeException and Error 以及他们的之类可以不用程序猿来声明处理
答:12.11 使用 throw 不能
答:12.12 throw 作用是抛出异常 throws 作用是声明异常
答:12.13 会执行 statement3 会 会
答:12.14 抛出 ArrayIndexOutOfBoundsException,
答:12.15 ArithmeticException。
答:12.16 StringIndexOutOfBoundsException
答:12.17 返回异常的描述
答:12.18 将信息跟踪到控制台
答:12.19 不会
答:12.20 public void m(int value ) throws Exception{
if(value<40)
Throw new Exception (“the value is too small”);
}
答:12.21 会执行 statement4 会
会 会
会 不会
答:12.22 它是正确的 但是最好是使用正则表达式来筛选
答:12.23 会 会
会 会
会 不会、