Question: Select the missing expression in the code fragment below. The method should continue to prompt the user for a valid integer value until one is
Select the missing expression in the code fragment below. The method should continue to prompt the user for a valid integer value until one is entered. The method returns the final value entered.
public static int getAge
boolean done false;
Scanner console new ScannerSystemin;
int value ;
while done
try
System.out.printPlease enter your age in years: ;
value console.nextInt;
done true;
System.out.printlnInvalid value. Try again.";
console.nextLine;
return value;
Question options:
catch IllegalArgumentException exception
finally
catch NumberFormatException exception
catch NoSuchElementException exception
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
