Solved

Consider the Following Code Snippet Written in Java 7

Question 90

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions