View the exhibit.
Given the code fragment:
Which change enables the code to print the following?
James age: 20 -
Williams age: 32 -
View the exhibit.
Given the code fragment:
Which change enables the code to print the following?
James age: 20 -
Williams age: 32 -
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.
Answer is A
C is wrong because 2nd and 3rd catch clauses are unreachable
Correct answer is B