Exception Handling

© examsiri.com
Question : 15 of 24
 
Marks: +1, -0
Class TestException
1. public class TestException extends Exception {
2. }
Class A:
1. public class A {
2.
3.   public String sayHello(String name) throws TestException {
4.
5.    if(name == null) {
6.     throw new TestException();
7.    }
8.
9.    return “Hello “+ name;
10.   }
11.
12. }

A programmer wants to use this code in an application:
13. A a=new A();
14. System.out.println(a.sayHello(”John”));

Go to Question: