Free Practice Exam - MCPD 70-562
Control Panel
Exam Progress
Move on to the next question
Links
Home
Microsoft Exams
Question 9
As part of programming best practices there are certain situations where a resource should be released even if an exception occurs in your code. Example of such cases include: opening and closing SQLConnections and opening and closing Streams. All unmanaged object must be closed or disposed of once code has finished using them.
If you want to adhere to this best practice which code block should you use to ensure they are disposed of correctly?
Try
Else
Catch
Finally
That was the correct answer, well done!
Sorry, that was the wrong answer
The correct answer is the Finally block. You should use the finally code block to execute any code regardless of the exception that did or did not occur. This is the ideal place to close connections and dispose of objects.
Sponsored
Free practice exams are provided free of charge by Accelerated Ideas. Please respect our exams and do not reproduce our material or abuse the testing system. Thank you. Microsoft exams for MCPD, MCTS, MCP, MCSE, MCSA, MCAD, MCSD