给定控制台应用程序的输出是什么?( )
public class Test31 {
public static void main(String[] args) {
test();
}
public static void test() {
try {
System.out.print("-try");
return;
} catch (Exception e) {
System.out.print("-catch");
} finally {
System.out.print("-finally");
}
}
}-try
-try-catch
-try-finally
-try-catch-finally
try代码块没有抛出异常,所以catch代码块没有运行。
finally代码块是必须运行的。
finally代码块是必须运行的。