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
Q99: Which of the following statements about the
Q100: Which of the following statements about exception
Q101: Consider the following code snippet: try
{
PrintWriter outputFile
Q102: Insert the missing code in the following
Q103: Insert the missing code in the following
Q104: Consider the following code snippet: Scanner in
Q105: Consider the following code snippet: try
{
File inputFile
Q107: Consider the following code snippet: try
{
PrintWriter outFile
Q108: Select the missing expression in the code
Q109: Consider the following code snippet: try
{
PrintWriter outputFile
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents