Question: QUESTION 5 int number; boolean done = false; do { try { System.out.print ( Enter an integer: ) ; number = console.nextInt (

QUESTION 5
int number;
boolean done = false;
do
{
try
{
System.out.print("Enter an integer: ");
number = console.nextInt();
System.out.println();
done = true;
System.out.println("number ="+ number);
}
catch (InputMismatchException imeRef)
{
str = console.next();
System.out.println("Exception "
+ imeRef.toString()
+""+ str);
}
}
while (!done);
How many times will the code in the try block above execute?
A. Until the user specifies that he/she wants to quit the program
B. Until the user inputs a valid integer
C. If there is an exception thrown it will execute just once because the program will terminate at that point.
D. Zero times; the program will terminate before it reaches the try block.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!