Difficulty: Easy
Correct Answer: 2 and 5 only
Explanation:
Introduction / Context:
This question checks core knowledge of C#.NET exception handling, especially the purpose and behavior of the finally block. Understanding which statements are universally true helps you write reliable cleanup logic and avoid misconceptions about abrupt termination.
Given Data / Assumptions:
Concept / Approach:
In standard execution, finally runs regardless of whether an exception is thrown or caught. It is the recommended place for deterministic cleanup, such as disposing resources or closing handles. A single try block may be followed by zero or more catch blocks and at most one finally block.
Step-by-Step Solution:
Verification / Alternative check:
Write sample code with try { … } catch { … } finally { Console.WriteLine("F"); }. You will observe the finally output in both success and failure cases.
Why Other Options Are Wrong:
Option A claims inevitable termination. Option D assumes multiple finally blocks per try. Option E ignores two clearly correct statements.
Common Pitfalls:
Believing finally will run even after process termination; misunderstanding that only one finally is allowed per try.
Final Answer:
2 and 5 only
Discussion & Comments