Hi all, I could not get this question right in Abhilash's exam site.Can someone please tell me why the answer is what it is. Question 36.
public class Base { public void aMethod() throws ClassNotFoundException { } } public class Derived extends Base { public void aMethod() throws RuntimeException { } } Assuming that the classes are in two seperate files, compilation of the Dervied.java causes
1.A compiler error because RuntimeException is not a subclass if ClassNotFoundException. 2.No compiler error. The answer according to Abhilash is 2.Why? Waiting for help. Thanks Gazala.
compiles fine because you can throw runtime exceptions not thrown in the overridden class, but you cannot throw checked exceptions in the overridden class. Bill