Which three are advantages of the Java exception mechanism?
A. Improves the program structure because the error handling code is separated from the normal program function
B. Provides a set of standard exceptions that covers all the possible errors
C. Improves the program structure because the programmer can choose where to handle exceptions
D. Improves the program structure because exceptions must be handled in the method in which they occurred
E. Allows the creation of new exceptions that are tailored to the particular program being created
题解
选项 A,分割一般程序和例外处理程序,能让程序的结构更浅显易懂。
选项 B,Java 内置多种例外种类,只包含程序实作层面可能会发生的错误,并非全部的错误,如因硬件损坏而出现难以辨识的错误或是程序逻辑上的错误。
选项 C,Java 的程序员可以自行决定程序的哪些部份要进行例外处理。
选项 D,例外不一定要在方法内进行处理,也可以将其丢出方法之外,交由线程来进行中断。
选项 E,可以针对特定程序创建新的例外。
