📜  Java |异常处理问题8

📅  最后修改于: 2021-06-29 04:23:31             🧑  作者: Mango

class Test
{
    public static void main (String[] args)
    {
        try
        {
            int a = 0;
            System.out.println ("a = " + a);
            int b = 20 / a;
            System.out.println ("b = " + b);
        }
  
        catch(ArithmeticException e)
        {
            System.out.println ("Divide by zero error");
        }
  
        finally
        {
            System.out.println ("inside the finally block");
        }
    }
}

(一)编译错误
(B)除以零误差
(C)

a = 0
Divide by zero error
inside the finally block

(D) a = 0
(E)最终块内答案: (C)
说明:用20除以0时,会发生除以零的异常,并且控制进入catch块内部。
另外,无论是否发生异常,总是执行finally块。这个问题的测验