Question: QUESTION 5 int number; boolean done = false; do { try { System.out.print ( Enter an integer: ) ; number = console.nextInt (
QUESTION
int number;
boolean done false;
do
try
System.out.printEnter an integer: ;
number console.nextInt;
System.out.println;
done true;
System.out.printlnnumber number;
catch InputMismatchException imeRef
str console.next;
System.out.printlnException
imeRef.toString
str;
while done;
How many times will the code in the try block above execute?
A Until the user specifies that heshe 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
