Exam 5: Control Structures II: Repetition

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

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

Free
(True/False)
4.8/5
(42)
Correct Answer:
Verified

True

A while loop is a post-test loop.

Free
(True/False)
4.7/5
(40)
Correct Answer:
Verified

False

In the case of an infinite while loop, the while expression (that is, the loop condition) is always true.

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

True

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
(43)

Which of the following is true about a while loop?

(Multiple Choice)
4.9/5
(40)

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

(True/False)
4.8/5
(27)

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
(36)

boolean found = false; Int num; Int square;while (!found) { Num = console.nextInt(); Square = num * num; If (square > 40) Found = true; }The above code is an example of a(n) ____ loop.

(Multiple Choice)
4.8/5
(40)

ch = inFile.next().charAt();while (inFile.hasNext()) { System.out.println(ch); Ch = inFile.next().charAt(); }The above code is an example of a(n) ____ loop.

(Multiple Choice)
4.7/5
(36)

What is value of x after the following code executes?int x = 0; Int i;for (i = 0; i < 5; i++) X = 3 * x + i;

(Multiple Choice)
4.7/5
(44)

int i;for (i = 0; i <= 10; i++) System.out.println("*"); System.out.println("!");Which of the following is the update expression in the for loop above?

(Multiple Choice)
4.8/5
(38)

Which executes immediately after a continue statement in a for loop?

(Multiple Choice)
4.9/5
(31)

Control variables are automatically initialized in a loop.

(True/False)
4.8/5
(36)

int x = 27; Int y = 10;do X = x / 3; While (x >= y);What is the final value of x in the code above?

(Multiple Choice)
4.8/5
(33)

The output of the following Java code is: Stoor.int count = 5; System.out.print("Sto");do { System.out.print('o'); count--; } while (count >= 5);System.out.println('r');

(True/False)
4.8/5
(35)

A break statement is legal in a while loop, but not in a for loop.

(True/False)
4.9/5
(32)

What is the output of the following Java code?int num = 15; While (num > 0) Num = num - 3; System.out.println(num);

(Multiple Choice)
4.9/5
(35)

What is the value of counter after the following statements execute?counter = 1; While (counter<30) Counter = 2 * counter;

(Multiple Choice)
5.0/5
(38)

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

(True/False)
4.8/5
(43)

int i;for (i = 0; i <= 10; i++) System.out.println("*"); System.out.println("!");Which of the following is the initial expression in the for loop above?

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

Filters

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