Exam 5: Loops and Files

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

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

Free
(True/False)
4.8/5
(42)
Correct Answer:
Verified

False

When you open a file with the PrintWriter class, the class can potentially throw an IOException.

Free
(True/False)
4.9/5
(32)
Correct Answer:
Verified

True

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

Free
(Multiple Choice)
4.9/5
(40)
Correct Answer:
Verified

D

In general, there are two types of files which are

(Multiple Choice)
4.8/5
(37)

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

(Multiple Choice)
4.8/5
(36)

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

(Multiple Choice)
5.0/5
(40)

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

(Multiple Choice)
5.0/5
(37)

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

(Multiple Choice)
4.8/5
(42)

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

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

(True/False)
4.7/5
(39)

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

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.

(Multiple Choice)
4.9/5
(48)

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

(Multiple Choice)
4.9/5
(28)

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

What does the following code do? Scanner keyboard = new Scanner(System.in); String filename; System.out.print("Enter the filename: "); Filename = keyboard.readString(); PrintWriter outFile = new PrintWriter(filename);

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

A __________ is a value that signals when the end of a list of values has been reached.

(Multiple Choice)
4.9/5
(36)

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

(Multiple Choice)
4.9/5
(37)

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

(Multiple Choice)
4.9/5
(38)

Select all that apply. Which of the following steps is normally performed by a for loop?

(Multiple Choice)
4.7/5
(30)
Showing 1 - 20 of 40
close modal

Filters

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