📜  Java |异常处理问题6

📅  最后修改于: 2021-07-02 17:33:59             🧑  作者: Mango

class Test
{
    public static void main(String[] args)
    {
        try
        {
            int a[]= {1, 2, 3, 4};
            for (int i = 1; i <= 4; i++)
            {
                System.out.println ("a[" + i + "]=" + a[i] + "\n");
            }
        }
          
        catch (Exception e)
        {
            System.out.println ("error = " + e);
        }
          
        catch (ArrayIndexOutOfBoundsException e)
        {
            System.out.println ("ArrayIndexOutOfBoundsException");
        }
    }
}

(A)编译器错误
(B)运行时错误
(C) ArrayIndexOutOfBoundsException
(D)打印错误代码
(E)列印阵列答案: (A)
说明: ArrayIndexOutOfBoundsException已被基类Exception捕获。当在基类异常之后提到子类异常时,就会发生错误。
这个问题的测验