Академический Документы
Профессиональный Документы
Культура Документы
jsp
16. What is one significant difference between a while loop and a do-while loop? Mark for Review
(1) Points
A DO-WHILE loop does not exist in Java and a WHILE loop does.
A DO-WHILE loop includes an int that serves as a counter and a WHILE loop does not.
There is no difference between a DO-WHILE loop and a WHILE loop.
A DO-WHILE loop will always execute the code at least once, even if the conditional
statement for the WHILE is never true. A WHILE loop is only executed if the conditional
statement is true. (*)
Correct
17. A counter used in a for loop cannot be initialized within the For loop statement. True or False? Mark for Review
(1) Points
True
False (*)
Correct
18. Which of the following is true about a do-while loop? Mark for Review
(1) Points
It is a post-test loop.
It is a modified while loop that allows the program to run through the loop once before
testing the boolean condition.
It continues looping until the condition becomes false.
All of the above. (*)
19. Consider that a Scanner has been initialized such that: Mark for Review
(1) Points
Scanner in = new Scanner(System.in);
Which of the following lines of code reads in the users input and sets it equal to a new String
called input?
String input = new String in.next();
String input = in.nextInt();
String input = in.next(); (*)
String input = in.close();
20. The following code fragment properly implements the switch statement. True or false? Mark for Review
(1) Points
default(input)
switch '+':
answer+=num;
break;
case '-':
answer-=num;
break;
!default
System.out.println("Invalid input");
True
False (*)
Correct