Oracle
1Z0-819 · Question #77
1Z0-819 Question #77: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-819 to reveal the answer and full explanation for question #77. The question stem and answer options stay visible for context.
Question
Given:
public class Test {
public static void doThings() throws GeneralException {
try {
throw new RuntimeException("Something happened");
} catch (Exception e) {
throw new SpecificException(e.getMessage());
}
}
public static void main(String args[]) {
try{
Test.doThings();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
class GeneralException /* line 1 / {
public GeneralException(String s) { super(s); }
}
class SpecificException / line 2 */ {
public SpecificException(String s) { super(s); }
}
Which option should you choose to enable the code to p int Something happened?
Options
- AAdd extends SpecificException on line 1. Add extends GeneralException on line 2.
- BAdd extends SpecificException on line 1 Add extends GeneralException on line 2
- CAdd extends Exception on line 1 Add extends Exception on line 2
- DAdd extends GeneralException on line 1 Add extends GeneralException on line 2
Unlock 1Z0-819 to see the answer
You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 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.