4. Which of the following statements about using the PrintWriter object with a file name is correct?
| If the output file already exists, the existing data will be discarded before new data are written into the file. |
| If the output file already exists, the new data will be appended to the end of the file. |
| If the output file does not exist, a FileNotFoundException will occur. |
| If the output file does not exist, an IllegalArgumentException will occur 5. Which of the following is NOT a typical usage of a Scanner object. | Format output for display to the screen | | Parse individual data fields directly from a String in memory | | Read input from the keyboard | | Read and parse a file from local storage | |
7. Which of the following statements about a PrintWriter object is true?
| No data loss will occur if the program fails to close a PrintWriter before exiting. |
| Data loss may occur if a program fails to close a PrintWriter object before exiting. |
| A PrintWriter will be automatically closed when the program exits. |
| An exception will occur if the program fails to close a PrintWriter before exiting. |
8.
One of the main points of exception handling in Java is to separate detection and handling of errors. Which of the following is NOT an advantage of this technique?
| Allows centralization of error handling |
| Allows decentralization of error detection |
| Can enforce a strict linear execution path |
| Can ensure certain resources are implicitly closed |