Python_Institute
PCPP-32-101 · Question #2
Analyze the following snippet and select the statement that best describes it.
The correct answer is B. The code is erroneous as the OwnMath class does not inherit from any Exception type class. OwnMath should be derived from BaseException. Run this code and you'll get an exception. If it is derived, it's an example of explicitly chained exception.
Advanced OOP
Question
Analyze the following snippet and select the statement that best describes it.
Exhibit
Options
- AThe code is an example of implicitly chained exceptions.
- BThe code is erroneous as the OwnMath class does not inherit from any Exception type class
- CThe code is fine and the script execution is not interrupted by any exception.
- DThe code is an example of explicitly chained exceptions
How the community answered
(53 responses)- A4% (2)
- B64% (34)
- C11% (6)
- D21% (11)
Explanation
OwnMath should be derived from BaseException. Run this code and you'll get an exception. If it is derived, it's an example of explicitly chained exception.
Topics
#exception chaining#custom exceptions#exception inheritance#explicit chaining
Community Discussion
No community discussion yet for this question.
