Bird
0
0

You want to create a custom exception for your application that inherits from the correct base class for user-defined exceptions. Which class should you inherit from?

hard🚀 Application Q8 of 15
C Sharp (C#) - Exception Handling
You want to create a custom exception for your application that inherits from the correct base class for user-defined exceptions. Which class should you inherit from?
AException
BSystemException
CApplicationException
DObject
Step-by-Step Solution
Solution:
  1. Step 1: Understand base classes for exceptions

    SystemException is for system errors; ApplicationException is intended for user-defined exceptions.
  2. Step 2: Choose appropriate base class for custom exceptions

    For custom exceptions, inheriting from ApplicationException is recommended to distinguish them from system exceptions.
  3. Final Answer:

    ApplicationException -> Option C
  4. Quick Check:

    Custom exceptions inherit ApplicationException [OK]
Quick Trick: Inherit ApplicationException for user-defined exceptions [OK]
Common Mistakes:
MISTAKES
  • Inheriting SystemException for custom exceptions
  • Inheriting Object instead of Exception

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes