Exam 4: Loops and Files

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

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

Free
(Multiple Choice)
4.8/5
(33)
Correct Answer:
Verified

A

Which of the following statements will create an object from the Random class?

Free
(Multiple Choice)
4.8/5
(35)
Correct Answer:
Verified

B

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

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

True

The variable used to keep a running total in a loop is called a(n) __________.

(Multiple Choice)
4.8/5
(37)

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

(Multiple Choice)
4.9/5
(40)

Which of the following are pre-test loops?

(Multiple Choice)
4.9/5
(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;

(Multiple Choice)
4.9/5
(38)

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

(Multiple Choice)
4.9/5
(44)

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

(Multiple Choice)
4.7/5
(34)

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

(Multiple Choice)
4.7/5
(36)

Select all that apply. Which method of the Random class will return a random number within the range of 0.0 and 1.0?

(Multiple Choice)
4.8/5
(35)

A random number, created as an object of the Random class, is always a(n) __________.

(Multiple Choice)
4.8/5
(44)

The variable that controls the number of times a loop iterates is known as a(n) __________.

(Multiple Choice)
4.7/5
(50)

In a for loop, the control variable cannot be initialized to a constant value and tested against a constant value.

(True/False)
4.8/5
(42)

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

(Multiple Choice)
4.8/5
(44)

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

(True/False)
4.8/5
(40)

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

(Multiple Choice)
4.8/5
(34)

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

(Multiple Choice)
4.8/5
(42)

What will be the values of x aand y after the following code is executed? int x = 12, y = 5; X += y--;

(Multiple Choice)
4.8/5
(35)

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
(43)
Showing 1 - 20 of 56
close modal

Filters

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