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. }
13. A a=new A();14. System.out.println(a.sayHello(”John”));