注意:此页面搜索的是所有试题
以下程序运行结果是( )
public class Ex20 {
public int div(int a, int b) {
try {
return a / b;
}catch (ArithmeticException e) {
System.out.print(" ArithmeticException ");
}catch(Exception e){
System.out.print(" Exception");
} finally {
System.out.print("finally");
}
return 0;
}
public static void main(String[] args) {
Ex20 demo = new Ex20();
System.out.print(" 商是:" + demo.div(9, 0));
}
}
A
Exception finally 商是:0
B
ArithmeticException finally 商是:0
C
finally商是:0
D
编译报错
public class Ex20 {
public int div(int a, int b) {
try {
return a / b;
}catch (ArithmeticException e) {
System.out.print(" ArithmeticException ");
}catch(Exception e){
System.out.print(" Exception");
} finally {
System.out.print("finally");
}
return 0;
}
public static void main(String[] args) {
Ex20 demo = new Ex20();
System.out.print(" 商是:" + demo.div(9, 0));
}
}
A
Exception finally 商是:0
B
ArithmeticException finally 商是:0
C
finally商是:0
D
编译报错
参考答案