public class A extends Exception {....}
public class B extends A {....}
public class C extends RuntimeException {....}
Given the method signature A bar(B q) throws C, which of the following will not compile?
A.
A m() throws C {
return bar(new B());
}
B.
m() {
return bar(new B());
}
C. All of the above will compile.
The answer is C. There might be a typo with B, not sure.
I'm not understanding this question, conceptually, what's it asking, etc.
I get A is a superclass of B, and C is alone as a RuntimeException, so it's not checked at compile time?
And I get the inside of the method has to be a B time exception, which works in both answers.
Could someone help explain why both of these compile?