• 2022-06-08
    分析以下代码,下面________ 陈述最准确?public class Test { public static void main(String[] args) { try { int zero = 0; int y = 2/zero; try { String s = "5.6"; Integer.parseInt(s); // Cause a NumberFormatException } catch(Exception e) { } } catch(RuntimeException e) { System.out.println(e); } }}
    A: 一个try-catch块不能嵌入另一个try-catch块中。
    B: 好的编程习惯是避免嵌套try-catch块,因为嵌套会使程序难以阅读。 最好只能使用一个try-catch块重写程序。
    C: 程序出现编译错误,因为Exception出现在RuntimeException之前。
    D: 其它都不对
  • 举一反三