Multiple Choice
Consider the following code snippet: PrintWriter outputFile = new PrintWriter(filename) ;
WriteData(outputFile) ;
OutputFile.close() ;
How can the program ensure that the file will be closed if an exception occurs on the writeData call?
A) The program does not need to take any action, because the output file will be automatically closed when the exception occurs.
B) The program should place the outputFile.close() statement within a try block to ensure that the file will be closed.
C) It is not possible to ensure that the file will be closed when the exception occurs.
D) The program should place the outputFile.close() statement within a finally clause of a try block to ensure that the file is closed.
Correct Answer:

Verified
Correct Answer:
Verified
Q15: Which of the following statements about checked
Q76: Consider the following code snippet: public double[]
Q77: Insert the missing code in the following
Q78: Consider the following code snippet: Scanner in
Q79: Which of the following statements about a
Q80: Select the missing expression in the code
Q82: Which of the following statements about the
Q83: Consider the following code snippet: File inputFile
Q85: Which of the following statements about reading
Q86: Consider the following code snippet. Scanner inputFile