Question:

Which of the following statements are correct?
A. Exception Handling can be done for only user-defined exceptions but not for built-in exceptions.
B. In python exception handling, else clause is optional.
C. Try statement in python must have a finally clause.
D. Statements in finally clause are always executed regardless of whether an exception has occurred in try block or not.
E. Except block will be executed only if some exception is raised in try block.
Choose the correct answer from the options given below:

Show Hint

Remember: try-except-finally is flexible—`finally` is optional, but if present, it always executes.
Updated On: Apr 28, 2025
  • A, B and D only
  • D and E only
  • C, D and E only
  • B, D and E only
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

- Statement A is incorrect because Python handles both built-in and user-defined exceptions. - Statement B is correct: the `else` clause is optional. - Statement C is incorrect: a `finally` clause is optional. - Statement D is correct: the `finally` block always executes. - Statement E is correct: the `except` block only runs if an exception occurs.
Was this answer helpful?
0
0