Java True/False 4
True
A file must always be opened before using it and closed when the program is finished using it.
False
In a for statement, the control variable can only be incremented.
False
In the for loop, the control variable cannot be initialized to a constant value and tested against a constant value.
True
Java provides a set of simple unary operators designed just for incrementing and decrementing variables.
False
The do-while loop is a pre-test loop.
True
The do-while loop must be terminated with a semicolon.
True
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.
False
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.
True
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
When you open a file with the PrintWriter class, the class can potentially throw an IOException.
True
You can use the PrintWriter class to open a file for writing and write data to it.
True
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.