给定
public class ToBeTestHandleException{
static class A {
void process() throws Exception {
throw new Exception();
}
}
static class B extends A {
void process() {
System.out.println("B ");
}
}
public static void main(String[] args) {
A a = new B();
a.process();
}
}
为什么我们要在 (a.process()) 行处理异常?. B 类的方法 process 根本不抛出异常?PS:这是一个 SCJP 问题。