C# Programming - Exception Handling - Discussion

Discussion :: Exception Handling - General Questions (Q.No.5)


Which of the following statements are correct about exception handling in C#.NET?

  1. If an exception occurs then the program terminates abruptly without getting any chance to recover from the exception.
  2. No matter whether an exception occurs or not, the statements in the finally clause (if present) will get executed.
  3. A program can contain multiple finally clauses.
  4. A finally clause is written outside the try block.
  5. finally clause is used to perform clean up operations like closing the network/database connections.

[A]. 1 only
[B]. 2 only
[C]. 2 and 5 only
[D]. 3 and 4 only
[E]. None of the above

Answer: Option C


No answer description available for this question.

Gowri said: (Oct 28, 2011)  
Which class is optional in Exception handling?

a) Finally
b) Catch
c) Throw
d) Try

Guest said: (May 2, 2013)  
In that Finally is not Class, it is block. It is optional also to include in try catch. But when use Try statement, at least one catch statement should present. Throw will also option, it is used only user want to throw user exception.

Santosh said: (Aug 19, 2013)  
Catch and finally are option block but you have to provide at least one of them catch or finally if you use a try block.




try {}



Not this:

Santosh said: (Aug 19, 2013)  
And yes this question is wrong you have to find incorrect option not correct option.

Andrue Cope said: (Oct 27, 2013)  
2, 3, 4 and 5 are all correct. Most likely as @Santosh wrote we are supposed to find the incorrect statement which is 1.

Vlad said: (Oct 10, 2014)  
Question 3 should be - try block can contain multiple finally clauses.

Chandu said: (Oct 26, 2014)  
According to me 2,4 & 5 is the right answer because, we can only write the finally block outside the try block, so option 3 holds good.

Ramprasad said: (Dec 10, 2015)  
2, 4, 5 is correct. It is not in the answers. A finally clause is written outside the try block.

Matthew said: (Apr 27, 2016)  
According to me, the question is wrong. A *program* CAN contain multiple finally clauses. It cannot be *single try block*.

Pritam said: (Jun 7, 2016)  
Yes, I agree @Matthew.

Surafel Kassahun said: (Jun 6, 2021)  
C# does not allow multiple finally blocks! And also finally block may or may not run every time depending on the type of exception that occurred.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.