阅读下面的程序,选择正确的说法?
public class ClassTest {
public static void main(String args[]) throws Exception{
method();
}
public static void method() throws Exception{
try { System.out.print("try:performed "); }
finally { System.out.println("finally:always performed"); }
}
}
A 编译该程序会显示产生编译错误,因为method()抛出异常,而调用它时没有进行处理
B 程序编译成功,运行该程序输出:try:performed finally:always performed
C 程序编译成功,运行该程序输出:try:performed
D 程序编译成功,运行该程序输出:finally:always performed
public class ClassTest {
public static void main(String args[]) throws Exception{
method();
}
public static void method() throws Exception{
try { System.out.print("try:performed "); }
finally { System.out.println("finally:always performed"); }
}
}
A 编译该程序会显示产生编译错误,因为method()抛出异常,而调用它时没有进行处理
B 程序编译成功,运行该程序输出:try:performed finally:always performed
C 程序编译成功,运行该程序输出:try:performed
D 程序编译成功,运行该程序输出:finally:always performed