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:
Verified
Q99: Which of the following statements about the
Q100: Which of the following statements about exception
Q101: Consider the following code snippet: try
{
PrintWriter outputFile
Q102: Insert the missing code in the following
Q103: Insert the missing code in the following
Q104: Consider the following code snippet: Scanner in
Q105: Consider the following code snippet: try
{
File inputFile
Q106: Consider the following code snippet written in
Q107: Consider the following code snippet: try
{
PrintWriter outFile
Q109: Consider the following code snippet: try
{
PrintWriter outputFile
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents