可学答题网 > 问答 > SCJP程序员认证考试题库
目录: 标题| 题干| 答案| 搜索| 相关
问题

Class TestException  1.&ens


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: 45. A a=new A();  46. System.out.println(a.sayHello(”John”));  Which two are true?()

  • 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.
参考答案
参考解析:
分类:SCJP程序员认证考试题库