单选题 运行下面的程序时,会产生{{U}} {{/U}}。
public class Test{
public static void main(String args[ ] ) {
int x =0;
int y = 2/x;
int z[ ] = {1,2,4,6};
int p=z[4];
}
}
  • A. ArrayIndexOutOfBoundsExcePtion异常
  • B. NumberFormatException异常
  • C. ArithmeticException异常
  • D. ArithmeticException异常和ArrayIndexOutOfBoundsExcePtion异常
【正确答案】 C
【答案解析】[解析] 只能出现ArithmeticException异常,由于在程序第4行出现了这个异常后,程序就跳出,不能继续执行下去,因此不会出现ArrayIndexOutOfBoundsException异常。