4. Given:
31. // some code here
32. try {
33. // some code here
34. } catch (SomeException se) {
35. // some code here
36. } finally {
37. // some code here
38. }
Under which three circumstances(情况)will the code on line 37 be executed? (Choose three.) A. The instance(实例) gets garbage(垃圾) collected(收集)。
B. The code on line 33 throws an exception.
C. The code on line 35 throws an exception.
D. The code on line 31 throws an exception.
E. The code on line 33 executes successfully.
我想问下 那个若是31行 有异常 程序是怎么处理的 还会在执行try catch么
31. // some code here
32. try {
33. // some code here
34. } catch (SomeException se) {
35. // some code here
36. } finally {
37. // some code here
38. }
Under which three circumstances(情况)will the code on line 37 be executed? (Choose three.) A. The instance(实例) gets garbage(垃圾) collected(收集)。
B. The code on line 33 throws an exception.
C. The code on line 35 throws an exception.
D. The code on line 31 throws an exception.
E. The code on line 33 executes successfully.
我想问下 那个若是31行 有异常 程序是怎么处理的 还会在执行try catch么
String a = null;
a.getBytes();
try {
throw new RuntimeException("2");
} finally {
System.out.println("3");
}
}
输出:Exception in thread "main" java.lang.NullPointerException
at test.ww.TestFinally.main(TestFinally.java:19)其实有时候自己测试一下就什么都明白了
不用着急问
2.如果执行到try里面语句,是否有异常 都必须执行finally的