Solved

Select the Missing Expression in the Code Fragment Below

Question 80

Multiple Choice

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 Scanner(System.in) ;
Int value = 0;
While (!done)
{
Try
{
System.out.print("Please enter your age in years: ") ;
Value = console.nextInt() ;
Done = true;
}
______________________
{
System.out.println("Invalid value. Try again.") ;
Console.nextLine() ;
}
}
Return value;
}


A) finally
B) catch (IllegalArgumentException exception)
C) catch (NoSuchElementException exception)
D) catch (NumberFormatException exception)

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions