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. - Answers True
In all but rare cases, loops must contain within themselves - Answers a way to terminate.
When the break 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. - Answers False
A for loop normally performs which of these steps? - Answers All of these
The do-while loop is ideal in situations where you always want the loop to iterate at least once. -
Answers True
Given the following statement, which statement will write the string "Calvin" to the file DiskFile.txt? -
Answers diskOut.println("Calvin");
You can use this method to determine whether a file exists. - Answers the File class's exists method
When working with the PrintWriter class, which of the following import statements should you have
near the top of your program? - Answers import java.io.*;
A loop that repeats a specific number of times is known as a(n) ________ loop. - Answers count-
controlled
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? - Answers int number = inputFile.nextInt();
A file must always be opened before using it and closed when the program is finished using it. - Answers
True
How many times will the following do-while loop be executed? - Answers 1
What will be the values of x and y as a result of the following code?
x=25,y=8;
x+=y++; - Answers x = 33, y = 9
How many times will the following for loop be executed?
java is great - Answers 12
The while loop is ideal in situations where the exact number of iterations is known. - Answers False
What does the following code do? - Answers Nothing syntax error
If a loop does not contain within itself a way to terminate, it is called - Answers an infinite loop.