1. 当方法trythis()被调用时,那输出是什么?()
publicvoid trythis()
{
try
{
System.out.print("1");
problem();
}
catch (RuntimeException x)
{
System.out.print("2");
return;
}
catch (Exception x )
{
System.out.print("3");
return;
}
finally
{
System.out.print("4");
}
System.out.print("5");
}
private void problem()throws Exception
{
throw new Exception();
}
A. "134”
B. "135"
C. "124"
D. "125"
E. "12345"
本文详细解析了一段Java代码中的异常处理流程,包括try、catch和finally块的执行顺序,以及不同类型的异常如何被捕获和处理。通过一个具体的示例,展示了当方法中抛出Exception类型异常时,程序如何响应并输出特定的字符串序列。
4万+

被折叠的 条评论
为什么被折叠?



