Which change enables the code to print the following?

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

A.
Replacing line 5 with public static void main (String [] args) throws MissingInfoException,
AgeOutofRangeException {

B.
Replacing line 5 with public static void main (String [] args) throws.Exception {

C.
Enclosing line 6 and line 7 within a try block and adding: catch(Exception e1) { //code
goes here} catch (missingInfoException e2) { //code goes here} catch
(AgeOutofRangeException e3) {//code goes here}

D.
Enclosing line 6 and line 7 within a try block and adding: catch (missingInfoException e2)
{ //code goes here} catch (AgeOutofRangeException e3) {//code goes here}



Leave a Reply 7

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


baba

baba

If not

B. right

A. Dosn’t catch Exception MissingInfoException != Exception
C. catch(Exception e1) catch (missingInfoException e2) fails // should be opposite
D. Dosn’t catch Exception same as A.

Kumaresh Babu

Kumaresh Babu

@baba you are right! answer is b

Roger Wilco

Roger Wilco

There is a point between throws and Exception in answer B (throws.Exception). Answer D makes the code print: James age: 20 Williams age: 32

Roger Wilco

Roger Wilco

I was wrong D does not do the job…