Oracle
1Z0-809 · Question #110
1Z0-809 Question #110: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #110. The question stem and answer options stay visible for context.
Question
Given the code fragment:
class UserException extends Exception { }
class AgeOutOfLimitException extends UserException { }
And the code fragment:
class App {
public void doRegister(String name, int age)
throws UserException, AgeOutOfLimitException {
if (name.length() < 5) {
throw new UserException();
} else if (age > 60) {
throw new AgeOutOfLimitException();
} else {
System.out.println("User is registered.");
}
}
public static void main (String [] args) throws UserException {
App t = new App ();
t.doRegister("Mathew", 60);
}
}
What is the result?Options
- AUser is registered.
- BAn AgeOutOfLimitException is thrown.
- CA UserException is thrown.
- DA compilation error occurs in the main method.
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 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.