Multiple Choice
Consider the following code snippet written in Java 7:
Try (PrintWriter outputFile = new PrintWriter(filename) )
{
WriteData(outputFile) ;
}
Which of the following statements about this Java 7 code is correct?
A) The program will terminate with an unhandled exception if the PrintWriter constructor fails.
B) The close method of the outputFile object will be automatically invoked when the try block ends, but only if no exception occurred.
C) The close method of the outputFile object will be automatically invoked when the try block ends, but only if an exception occurs.
D) The close method of the outputFile object will be automatically invoked when the try block ends, whether or not an exception has occurred.
Correct Answer:

Verified
Correct Answer:
Verified
Q6: Which of the following statements about exception
Q10: What is the purpose of the throw
Q36: Your program must read in an existing
Q55: Consider the following code snippet. Scanner in
Q66: Your program wishes to open a file
Q72: Which of the following statements about exception
Q73: Consider the following code snippet: Scanner in
Q90: When reading words with a Scanner object,
Q94: Consider the following code snippet:<br>Public double[] readInputFile(String
Q101: Consider the following code snippet: Scanner in