C# - Exception Handling Questions and Answers
C# Exception Handling is a crucial topic in programming interviews and technical assessments. This section provides comprehensive programming questions and answers related to handling runtime errors in C#. Understanding exception handling helps developers write reliable code that gracefully manages unexpected events using constructs like try, catch, finally, and throw. These C# programming MCQs and interview-based examples are often seen in company placement tests such as TCS, Infosys, Wipro, and Capgemini. Practicing these C# exception handling questions with answers will strengthen your understanding of error handling and help you prepare for real-world coding challenges as well as competitive programming rounds.
C# - Exception Handling
Showing 10 of
30 questions
11. What is the purpose of exception handling in C#?
- To prevent compilation errors
- To handle runtime errors
- To improve code readability
- To increase application speed
13. What does the finally block do in exception handling?
- Executes only when no exception occurs
- Executes only when exception occurs
- Always executes
- Never executes
14. Which exception is thrown when dividing by zero?
- ArithmeticException
- DivideByZeroException
- MathException
- CalculationException
15. What is the base class for all exceptions in C#?
- System.Exception
- System.SystemException
- System.ApplicationException
- System.BaseException
16. Which keyword is used to throw an exception explicitly?
- throws
- exception
- raise
- throw
17. What happens if an exception is not caught?
- Exception is ignored
- Application continues normally
- Application terminates
- Exception is logged automatically
18. Which block is used to clean up resources in exception handling?
- try
- catch
- finally
- using
19. What is the purpose of multiple catch blocks?
- To improve performance
- To handle different exception types
- To make code more complex
- To reduce code size
20. Which exception is thrown when accessing a null object?
- NullException
- NullReferenceException
- ObjectNotFoundException
- NullObjectException