Q:
You responsible for maintaining an application that was written by a former colleague at XYZ.
The application reads from and writes to log files located on the local network. The original author included the following debugging code to facilitate maintenance:
try {
Debug.WriteLine(“Inside Try”);
throw(new IOException());}
catch (IOException e) {
Debug.WriteLine (“IOException Caught”);}
catch (Exception e) {
Debug.WriteLine(“Exception Caught”);}.
finally {
Debug.WriteLine (“Inside Finally”);}
Debug.WriteLine (“After End Try”);
Which output is produced by thus code?
Answer & Explanation
Answer: C) Inside Try IOException Caught Inside Finally After End Try
Explanation: First the try code runs. Then one single exception, the IOException occurs, not two exceptions.Then the Finally code segments executes. After Finally code bas been executed normal application resumes at the next line after the line that called the error. In this case, the After End Try code runs.
View Answer
Report Error
Discuss