RR Java Chapter 4

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

conditional

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

iteration

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

this is an infinite loop

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

110

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

40

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;

x = 33, y = 9

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

Numbers in the range 100 - 500

n the following code, what values could be read into number to terminate the while loop? Scanner keyboard = new Scanner(System.in); System.out.print("Enter a number: "); int number = keyboard.nextInt(); while (number < 100 || number > 500) { System.out.print("Enter another number: "); number = keyboard.nextInt(); }

5

How many times will the following do-while loop be executed? int x = 11; do{x += 20;} while (x <= 100);

12

How many times will the following for loop be executed? for (int count = 10; count <= 21; count++) System.out.println("Java is great!");

infinite

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

a way to terminate

In all but very rare cases, loops must contain, within themselves ________.

for

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

int number = inputFile.nextInt();

Assuming that inputFile references a Scanner object that was used to open a file, which of the following statements will read an int from the file?

set the accumulator variable to an initial value, often zero

Before entering a loop to compute a running total, the program should first ________.

5, 8, 11, 14,

What will be printed after the following code is executed? for (int number = 5; number <= 15; number +=3) System.out.print(number + ", ");


Set pelajaran terkait

Lifespan Development Ch 7. Early Childhood

View Set

MARK 380 Digital Marketing Overview

View Set

ap Computer Science exam questions

View Set

Principles of Management: Chapter 10 (Wesson)

View Set

Mental Health Exam 4 CH 16, 17, 22, 24, 26 & 27

View Set