单选题:以下程序运行结果是
以下程序运行结果是 @[D](2)
```
public class Test {
public int div(int a, int b) {
try {
return a / b;
}catch(Exception e){
System.out.println(“Exception”);
}catch(NullPointerException e){
System.out.println(“ArithmeticException”);
}
catch (ArithmeticException e) {
System.out.println(“ArithmeticException”);
} finally {
System.out.println(“finally”);
}
return 0;
}
public static void main(String[] args) {
Test demo = new Test();
System.out.println(“商是:” + demo.div(9, 0));
}
}
```
A. Exception finally 商是:0
B. ArithmeticException finally 商是:0
C. finally商是:0
D. 编译报错
A.Exception finally 商是:0
B.ArithmeticException finally 商是:0
C.finally商是:0
D.编译报错
答案:D
```
public class Test {
public int div(int a, int b) {
try {
return a / b;
}catch(Exception e){
System.out.println(“Exception”);
}catch(NullPointerException e){
System.out.println(“ArithmeticException”);
}
catch (ArithmeticException e) {
System.out.println(“ArithmeticException”);
} finally {
System.out.println(“finally”);
}
return 0;
}
public static void main(String[] args) {
Test demo = new Test();
System.out.println(“商是:” + demo.div(9, 0));
}
}
```
A. Exception finally 商是:0
B. ArithmeticException finally 商是:0
C. finally商是:0
D. 编译报错
A.Exception finally 商是:0
B.ArithmeticException finally 商是:0
C.finally商是:0
D.编译报错
答案:D