Oracle
1Z0-851 · Question #177
1Z0-851 Question #177: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #177. The question stem and answer options stay visible for context.
Question
Given: 01. class TestException extends Exception { } 02. class A { 03. public String sayHello(String name) throws TestException { 04. if(name == null) throw new TestException(); 05 return "Hello " + name; 06. } 07. } 08. public class TestA { 09. public static void main(String[] args) { 10. new A().sayHello("Aiko"); 11. } 12. } Which statement is true?
Options
- ACompilation succeeds.
- BClass A does not compile.
- CThe method declared on line 9 cannot be modified to throw TestException.
- DTestA compiles if line 10 is enclosed in a try/catch block that catches TestException.
Unlock 1Z0-851 to see the answer
You've previewed enough free 1Z0-851 questions. Unlock 1Z0-851 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.