Java 4B QUIZ (loops)

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

A loop that executes as long as a particular condition exists is called a(n) ________ loop

conditional

A loop that repeats a specific number of times is known as a(n) ________ loop.

count-controlled

In a for loop, the control variable cannot be initialized to a constant value and tested against a constant value.

false

In a for loop, the control variable is always incremented.

false

If a loop does not contain, within itself, a valid way to terminate, it is called a(n) ________ loop

infinite

Each repetition of a loop is known as a(n) ________.

iteration

Which is a control structure that causes a statement or group of statements to repeat?

loop

The variable that controls the number of times a loop iterates is known as a ________.

loop control variable

A ________ loop will always be executed at least once.

posttest

A(n) ________ is a special value that cannot be mistaken as a member of a list of data items and signals that there are no more data items to be processed.

sentinel

What will be the value of x after the following statements are executed? int x = 10; for (int y = 5; y < 20; y +=5) x += y;

40

The while loop is always the best choice in situations where the exact number of iterations is known.

false

The ________ loop is ideal in situations where the exact number of iterations is known.

for

The do-while loop is ideal in situations where you always want the loop to iterate at least once.

true

The do-while loop must be terminated with a semicolon.

true

The while loop has two important parts: (1) a boolean expression that is tested for a true or false value, and (2) a statement or block of statements that is repeated as long as the expression is true.

true

Which of the following are pre-test loops?

while, for

What will be the values of x and y as a result of the following code? int x = 25, y = 8; x += y++;

x=33, y=9

What will be the value of x after the following code is executed? int x = 10; while (x < 100) { x += 100; }

110

What will be the value of x after the following code is executed? int x, y = 4, z = 6; x = (y++) * (++z);

28


Kaugnay na mga set ng pag-aaral

Anatomy chapter 8: the skeletal system articulations (exam #2)

View Set

Nn Write the words in the correct box. (page 15)

View Set

2019FA CJC 141 Corrections Pitt Community College CHP 6

View Set