Exam 4: Loops and Files

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

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/False)
4.7/5
(36)

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

(Multiple Choice)
4.9/5
(35)

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

(Multiple Choice)
4.8/5
(37)

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

(Multiple Choice)
4.8/5
(38)

This is a sum of numbers that accumulates with each iteration of a loop.

(Multiple Choice)
4.8/5
(34)

Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops shows the correct way to read data from the file until the end of the file is reached?

(Multiple Choice)
4.9/5
(40)

Which of the following are pre-test loops?

(Multiple Choice)
4.9/5
(33)

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

(Multiple Choice)
4.7/5
(40)

This type of loop is ideal in situations where the exact number of iterations is known.

(Multiple Choice)
5.0/5
(36)

Which of the following will open a file named MyFile.txt and allow you to read data from it?

(Multiple Choice)
4.9/5
(33)

In all but rare cases, loops must contain within themselves

(Multiple Choice)
4.9/5
(36)

____________ is the process of inspecting data given to the program by the user and determining if it is valid.

(Multiple Choice)
4.8/5
(38)

This variable controls the number of times that the loop iterates.

(Multiple Choice)
4.9/5
(44)

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

(Multiple Choice)
4.9/5
(32)

You can use the PrintWriter class to open a file for writing and write data to it.

(True/False)
4.9/5
(43)

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

(Multiple Choice)
4.9/5
(37)

What will be the value of x after the following code is executed? int x = 10; Do { X *= 20; } While (x < 5);

(Multiple Choice)
4.7/5
(39)
Showing 41 - 57 of 57
close modal

Filters

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