A programmer wants to use this code in an application:
Which two are true? (Choose two.)
A. Class A will not compile.
B. Line 46 can throw the unchecked exception TestException.
C. Line 45 can throw the unchecked exception TestException.
D. Line 46 will compile if the enclosing method throws a TestException.
E. Line 46 will compile if enclosed in a try block, where TestException
is caught.
Here the answers are , D,E.
I can understand E is correct, as Line 46 should be enclosed in try{} block and the exception will be caught. Since the sayHello(
String name) method in class A does not catch the TestException, so as line 46 calls the sayHello() method, the TestException should be caught there.
But i dont understand why the answer D is right. If enclosing method throws TestException, then how come Line 46 will compile?