Exam 4: Loops and Files

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

Which of the following statements opens a file named MyFile.txt and allows you to append data to its existing contents?

(Multiple Choice)
4.8/5
(28)

A file must always be opened before using it and closed when the program is finished using it.

(True/False)
4.7/5
(45)

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

(Multiple Choice)
4.7/5
(44)

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

When you pass the name of a file to the PrintWriter constructor and the file already exists, it will be erased and a new empty file with the same name will be created.

(True/False)
4.9/5
(27)

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

(Multiple Choice)
4.9/5
(41)

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

(Multiple Choice)
4.8/5
(37)

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

(Multiple Choice)
4.9/5
(35)

What will be the value of x after the following code is executed? int x, y = 15; X = y--;

(Multiple Choice)
4.8/5
(28)

When the continue statement is encountered in a loop, all the statements in the body of the loop that appear after it are ignored, and the loop prepares for the next iteration.

(True/False)
4.8/5
(48)

When working with the PrintWriter class, which of the following import statements should you have near the top of your program?

(Multiple Choice)
4.9/5
(34)

The __________ loop allows the user to decide on the number of iterations.

(Multiple Choice)
4.8/5
(35)

Which of the following is the method you can use to determine whether a file exists?

(Multiple Choice)
4.7/5
(34)

In 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(); }

(Multiple Choice)
4.9/5
(37)

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

A __________ loop will always be executed at least once.

(Multiple Choice)
4.8/5
(36)
Showing 41 - 56 of 56
close modal

Filters

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