What is the result?

Given:
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 () < 6) {
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?

Given:
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 () < 6) {
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?

A.
User is registered.

B.
An AgeOutOfLimitException is thrown.

C.
A UserException is thrown.

D.
A compilation error occurs in the main method.



Leave a Reply 10

Your email address will not be published. Required fields are marked *


sil

sil

B is correct

dazladhoyya

dazladhoyya

C:\Users\Chloe\Documents>javac App.java

C:\Users\Chloe\Documents>java App
Exception in thread “main” AgeOutOfLimitException
at AppQ1.doRegister(AppQ1.java:11)
at AppQ1.main(AppQ1.java:18)

C:\Users\Chloe\Documents>

dazladhoyya

dazladhoyya

if (age >= 60) {
throw new AgeOutOfLimitException ();
———————————————————————–
and
t.doRegister(“Mathew”, 60); // age is equal to 60, so exception thrown

v10

v10

Most of the answers in this briefing (1z0-809) are NOT correct.

Berti John

Berti John

B. is correct

dieselsilvester

dieselsilvester

Correct Answer: A

By making 1z0-809 dumps pdf your choice, you can easily ace your Oracle by the first attempt. This handy dumps material has changed the way candidates used to prepare their exam by taking help from different places which was a time wasting and hard task. 1z0-809 exam dumps gives you apposite knowledge about each concept. Clarity and comprehensiveness are the tools of Dumps4download.com. You are familiarized with the questions which you will, most probably, face in your exam. This material can be downloaded in PDF for your best reading experience but before downloading complete file you have the option to download Free Demo Questions to be satisfied with the quality of the stuff. https://www.dumps4download.com/1z0-809-dumps.html