try catch finally
来源:互联网 发布:小时代讲的什么知乎 编辑:程序博客网 时间:2024/06/05 09:38
1 如下的程序输出的结果正确的是()
public class Test1 {
public static String output =”“;
public static void foo(int i)
{
try{
if(i == 1)
{
throw new Exception();
}
}catch(Exception e){
output+=”2”;
//return;
}finally {
output+=”3”;
}
output+=”4”;
}
public static void main(String[] args) {
foo(0);
foo(1);
System.out.println(output);
}
}
A error
B 342
C 34234
D 3423
注解:对于try catch finally
finally肯定会执行,其次,如果出现异常,且异常语句块没有return的话,try~finally语句块的外层的语句也会执行,并且是try~finally执行完成后执行,总之外围的语句块再某种程度上,也是会执行的。在try语句和catch语句执行return之前肯定会先执行finally 的语句块。
- try..catch..finally
- try-catch-finally
- Try-catch-finally机制
- 关于try-catch-finally
- C# try catch finally
- try...catch...finally
- try catch finally用法
- Try ---Catch----Finally
- try...catch... finally
- try....catch...finally 妙用
- try{} catch(){}finally{}执行
- Try Catch Finally
- try-catch-finally
- C# try, catch ,finally
- try catch finally
- try catch finally
- try-catch-finally
- try...catch...finally
- 3-6 静态数据成员与静态成员函数
- volatile
- Android适配
- 使用cookie实现一周内自动登录
- Spring源码解析——如何阅读源码
- try catch finally
- Technocup 2017 - Elimination Round 1 A题
- Android Service的启动过程
- http中14个常用状态码
- 找球号(三)
- 使用UIImagePickerController实现 iOS录像拍照
- Codeforces Round #376 (Div. 2) F Video Cards
- 编译器的优化问题
- hdu1155Bungee Jumping+物理数学计算