Given:
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();
}
In this question, when I call a.process()
, it will give me a compile time error, saying, "Unhandled exception must be handled". But, if the parent method is throwing any checked exception, its not necessary to handle that exception in the child if we are overriding the parent's implementation.
Why is the exception still checked?