运行下面的程序时,会产生(  )。 public class Test{ public static void main(String args[ ] ) { int x =0; int y

admin2010-12-17  31

问题 运行下面的程序时,会产生(  )。     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异常。
转载请注明原文地址:https://jikaoti.com/ti/L2H0FFFM
0

最新回复(0)