Wednesday, 18 September 2013

Throw Error, Exception and Runtime Exception in child class

Throw Error, Exception and Runtime Exception in child class

I'm trying to understand the difference why a child class cannot override
a method implementation in the parent class to catch an Exception but no
problem while catching a Error,
For example in the below scenario, when I remove "Exception" from the
throws clause, it compiles fine.
class Supertest {
public void amethod(int i, String s) {
}
}
public class test extends Supertest {
public void amethod(int i, String s) throws Error, Exception {
}
}

No comments:

Post a Comment