class X extends Exception {
}
class Y extends X {
}
class Z extends Y {
}
public class Test {
static void aMethod() throws Z {
throw new Z();
}
public static void main(String[] args){
int x = 10;
try {
aMethod();
}
catch(X e) {
System.out.println(“Error X”);
}
catch(Y e) {
System.out.println(“Error Y”);
}
}
}
输出是什么?
(A) 两个 catch 块都不会捕获异常
(B) 它将打印“错误 X”</p>
(C) 它将打印“错误 Y”</p>