Exam 5: Control Structures II: Repetition

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

The do...while loop has an exit condition but no entry condition.

Free
(True/False)
4.9/5
(41)
Correct Answer:
Verified

True

Which of the following is true about a while loop?

Free
(Multiple Choice)
4.9/5
(31)
Correct Answer:
Verified

C

If y = 0, how many times would the loop above execute?

Free
(Multiple Choice)
4.7/5
(41)
Correct Answer:
Verified

D

The loop condition of a while loop is reevaluated before every iteration of the loop.

(True/False)
4.8/5
(33)

The control statements in the for loop include the initial expression, logical expression, and update expression.

(True/False)
4.9/5
(37)

In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.

(True/False)
4.9/5
(40)

To read data from a file of unspecified length, an EOF-controlled while loop is a better choice than a counter-controlled while loop.

(True/False)
4.8/5
(36)

The above code is an example of a(n) ____ loop.

(Multiple Choice)
4.8/5
(38)

Which of the following is not a function of the break statement?

(Multiple Choice)
4.9/5
(43)

In the for statement, if the logical expression is omitted, it is assumed to be false.

(True/False)
4.8/5
(33)

The following for loop executes 21 times. (Assume all variables are properly declared.) for (i = 1; i <= 20; i = i + 1) System.out.println(i);

(True/False)
4.9/5
(33)

Assume that all variables in the following code are properly declared and that the input is 3 7 4 -1. The output is 13. num = console.nextInt(); sum = num; while (num != -1) {num = console.nextInt(); sum = sum + num;} System.out.println(sum);

(True/False)
4.8/5
(45)

Which of the following is the logical expression in the for loop above?

(Multiple Choice)
4.8/5
(43)

A loop is a control structure that causes certain statements to be executed over and over until certain conditions are met.

(True/False)
5.0/5
(45)

The output of the Java code, assuming that all variables are properly declared, is 32. num = 10; while (num <= 32) num = num + 5; System.out.println(num);

(True/False)
4.8/5
(45)

The output of the Java code, assuming that all variables are properly declared, is: 2 3 4 5 6. n = 2; while (n >= 6) {System.out.print(n + " "); n++;} System.out.println();

(True/False)
4.9/5
(37)

Which of the following is the update expression in the for loop above?

(Multiple Choice)
4.8/5
(33)

What is the output of the following code? int count; int num = 2; for (count = 1; count < 2; count++) {num = num + 3; System.out.print(num + " ");} System.out.println();

(Multiple Choice)
4.8/5
(46)

The above code is an example of a(n) ____ while loop.

(Multiple Choice)
4.8/5
(26)

Which of the following is the initial expression in the for loop above?

(Multiple Choice)
4.9/5
(28)
Showing 1 - 20 of 50
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)