下列代码的执行结果是( )。 public c1ass Test { public static vold mai n(Stri ng[]args){ i nt[]x={0,1,2,3}; for {i nt i =0;i <3;1+=2){

admin2012-12-02  49

问题 下列代码的执行结果是(  )。
public c1ass Test {
public static vold mai n(Stri ng[]args){
  i nt[]x={0,1,2,3};
  for {i nt i =0;i <3;1+=2){
   try {
systc m.out .pri ntln(x[i +2]/x[i]+x[i +1]);
   }
catch (ArithmeticException e){
    Syste m.out .pri ntln("errorl");
   }
catch (Exception e){
    Syste m.out .pri ntln ("error2");
   }
  }


选项 A、error1
B、error2
C、error1orror2
D、2error2

答案C

解析 当0作为除数时,会产生异常,而ArithmeticException 和Exception 两类异常都内部被捕捉到。
转载请注明原文地址:https://jikaoti.com/ti/lbkiFFFM
0

相关试题推荐
最新回复(0)