Exam 1z0-803 All QuestionsBrowse all questions from this exam
Question 15

View the exhibit.

Given the code fragment:

Which change enables the code to print the following?

James age: 20 -

Williams age: 32 -

    Correct Answer: B

    The proper way to handle exceptions thrown by the Candidate constructor is to declare that the main method throws these exceptions, given that they are checked exceptions and need to be either caught or declared to be thrown. Replacing line 5 with 'public static void main (String [] args) throws Exception {' will ensure that any MissingInfoException or AgeOutofRangeException thrown within the main method are properly declared and allow the program to compile and run, producing the desired output with the Candidate objects.

Discussion
TatudevOption: A

Answer is A

Nate88890123Option: B

C is wrong because 2nd and 3rd catch clauses are unreachable

Nate88890123Option: B

Correct answer is B