Exam 5: Control Structures II: Repetition

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

Which of the following is NOT a reserved word in Java?

(Multiple Choice)
4.9/5
(37)

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.9/5
(37)

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.8/5
(34)

A syntax error will result if the control statements of a for loop are omitted.

(True/False)
4.8/5
(44)

Which of the following does not have an entry condition?

(Multiple Choice)
4.7/5
(40)

If a continue statement is placed in a do...while structure, the loop-continue test is evaluated immediately after the continue statement.

(True/False)
4.8/5
(36)

What is the tenth Fibonacci number in the sequence above?

(Multiple Choice)
4.8/5
(39)

Suppose sum and num are int variables, and the input is 20 25 10 18 -1 What is the output of the following code? (Assume that console is a Scanner object initialized to the standard input device.) sum = 0; num = console.nextInt(); while (num != -1) {if (num >= 20) sum = sum + num; else sum = sum - num; num = console.nextInt();} System.out.println(sum);

(Multiple Choice)
4.7/5
(34)

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

(Multiple Choice)
4.9/5
(37)

Which executes first in a do...while loop?

(Multiple Choice)
4.7/5
(34)

How many times does the statement above execute?

(Multiple Choice)
4.9/5
(41)

Control variables are automatically initialized in a loop.

(True/False)
5.0/5
(41)

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

(Multiple Choice)
4.7/5
(36)

Which of the following loops is guaranteed to execute at least once?

(Multiple Choice)
4.7/5
(40)

A while loop is a post-test loop.

(True/False)
4.9/5
(34)

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.7/5
(38)

Which of the following is true about a do...while loop?

(Multiple Choice)
4.9/5
(33)

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

(True/False)
4.7/5
(39)

What is the final value of x in the code above?

(Multiple Choice)
4.9/5
(38)
Showing 21 - 40 of 50
close modal

Filters

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