QUESTION 44자격증/OCJP_ExamB2018. 7. 13. 19:03
Table of Contents
반응형
QUESTION 44
Given:
1. class TestException extends Exception { }2. class A {3. public String sayHello(String name) throws TestException {4. if(name == null) throw new TestException();5. return "Hello " + name;6. }7. }8. public class TestA {9. public static void main(String[] args) {10. new A().sayHello("Aiko");11. }12. }Which statement is true?A. Compilation succeeds.B. Class A does not compile.C. The method declared on line 9 cannot be modified to throw TestException.D. TestA compiles if line 10 is enclosed in a try/catch block that catches TestException.Solution : D
plus imformation
Main.java:10: unreported exception TestException;
must be caught or declared to be thrown
new A().sayHello("Aiko");
^
1 error
반응형
'자격증 > OCJP_ExamB' 카테고리의 다른 글
QUESTION 46 (0) | 2018.07.13 |
---|---|
QUESTION 45 (0) | 2018.07.13 |
QUESTION 43 (0) | 2018.07.13 |
QUESTION 42 (0) | 2018.07.13 |
QUESTION 41 (0) | 2018.07.11 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상