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
Q9: Which Java class implements a file dialog
Q10: What is the purpose of the throw
Q11: Consider the following code snippet: Scanner in
Q12: Consider the following code snippet: public static
Q13: Consider the following code snippet:<br>If (in.hasNextDouble())<br>{<br>Number =
Q15: Consider the following code snippet. File hoursFile
Q16: Assume that inputFile is a Scanner object
Q17: You wish to use the Scanner class's
Q18: Insert the missing code in the following
Q19: Consider the following code snippet: Scanner in