Exam 4: Loops and Files

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

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?

(Multiple Choice)
4.8/5
(44)

If you are using a block of statements, don't forget to enclose all of the statements in a set of:

(Multiple Choice)
4.8/5
(43)

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

(Multiple Choice)
4.9/5
(37)

A for loop normally performs which of these steps?

(Multiple Choice)
4.9/5
(31)

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

(Multiple Choice)
4.9/5
(36)

A sentinel value _________ and signals that there are no more values to be entered.

(Multiple Choice)
4.8/5
(35)

Java provides a set of simple unary operators designed just for incrementing and decrementing variables.

(True/False)
4.7/5
(48)

What will be the value of x after the following code is executed? int x = 10; For (int y = 5; y < 20; y +=5) X += y;

(Multiple Choice)
4.8/5
(47)

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

Which of the following will open a file named MyFile.txt and allow you to append data to its existing contents?

(Multiple Choice)
4.8/5
(27)

This type of loop is ideal in situations where you always want the loop to iterate at least once.

(Multiple Choice)
4.8/5
(43)

The increment operator is:

(Multiple Choice)
4.8/5
(38)

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

(Multiple Choice)
4.8/5
(33)

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

(Multiple Choice)
4.9/5
(48)

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

Given the following statement, which statement will write "Calvin" to the file DiskFile.txt? PrintWriter diskOut = new PrintWriter("DiskFile.txt");

(Multiple Choice)
4.9/5
(33)

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

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

(True/False)
4.8/5
(37)

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)

This type of loop allows the user to decide the number of iterations.

(Multiple Choice)
4.8/5
(39)
Showing 21 - 40 of 57
close modal

Filters

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