问题
单项选择题
下列代码的执行结果是( )。
public class Test
public static void main(String[]args)
int[]x=0,1,2,3;
forint i=0;i<3;1+=2)
try
system.out.println(x[i+2]/x[i]+x[i+1]);
catch(ArithmeticException e)
System.out.println("error1");
catch(Exception e)
System.out.println("error2");
A.error1
B.error2
C.error1
orror2
D.2
error2
答案
参考答案:C
解析: 当0作为除数时,会产生异常,而ArithmeticException和Exception两类异常都内部被捕捉到。