123456789101112131415



Question 1: class TestException extends Exception { }
class A {
public String sayHello(String name) throws TestException {
if(name == null) throw new TestException();
return "Hello " + name;
}
}
public class TestA {
public static void main(String[] args) {
new A().sayHello("Aiko");
}
}
Which statement is true?

1. Compilation succeeds.
2. Class A does not compile.
3. The method declared on line 9 cannot be modified to throw TestException.
4. TestA compiles if line 10 is enclosed in a try/catch block that catches TestException.