nerdexam
Oracle

1Z0-809 · Question #276

QUESTION 301 Given class UserException extends Exception { } class AgeOutOfLimitException extends UserException { } and the code fragment: public class App { public static void doRegister (String…

The correct answer is C. A UserException is thrown. You've hit your session limit · resets 5:20pm (America/New_York)

Question

QUESTION 301 Given class UserException extends Exception { } class AgeOutOfLimitException extends UserException { } and the code fragment: public class App { public static void doRegister (String name, int age) throws UserException, AgeOutOfLimitException { if (name.length () < 60) { 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.

How the community answered

(19 responses)
  • A
    11% (2)
  • C
    84% (16)
  • D
    5% (1)

Explanation

You've hit your session limit · resets 5:20pm (America/New_York)

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice