C# - Exception Handling Questions and Answers

Practice Mode
Showing 10 of 30 questions
Q11
What is the purpose of exception handling in C#?
  • A To prevent compilation errors
  • B To handle runtime errors
  • C To improve code readability
  • D To increase application speed
Answer: Option B
Explanation: Exception handling manages runtime errors to maintain normal application flow.
Q12
Which keyword is used to handle exceptions in C#?
  • A handle
  • B catch
  • C try
  • D exception
Answer: Option C
Explanation: try-catch blocks are used for exception handling.
Q13
What does the finally block do in exception handling?
  • A Executes only when no exception occurs
  • B Executes only when exception occurs
  • C Always executes
  • D Never executes
Answer: Option C
Explanation: Finally block always executes regardless of exception occurrence.
Q14
Which exception is thrown when dividing by zero?
  • A ArithmeticException
  • B DivideByZeroException
  • C MathException
  • D CalculationException
Answer: Option B
Explanation: DivideByZeroException occurs on division by zero operations.
Q15
What is the base class for all exceptions in C#?
  • A System.Exception
  • B System.SystemException
  • C System.ApplicationException
  • D System.BaseException
Answer: Option A
Explanation: System.Exception is the root class for all exceptions.
Q16
Which keyword is used to throw an exception explicitly?
  • A throws
  • B exception
  • C raise
  • D throw
Answer: Option D
Explanation: throw keyword manually raises exceptions.
Q17
What happens if an exception is not caught?
  • A Exception is ignored
  • B Application continues normally
  • C Application terminates
  • D Exception is logged automatically
Answer: Option C
Explanation: Uncaught exceptions terminate the application.
Q18
Which block is used to clean up resources in exception handling?
  • A try
  • B catch
  • C finally
  • D using
Answer: Option C
Explanation: Finally block ensures resource cleanup.
Q19
What is the purpose of multiple catch blocks?
  • A To improve performance
  • B To handle different exception types
  • C To make code more complex
  • D To reduce code size
Answer: Option B
Explanation: Multiple catch blocks handle different exception types specifically.
Q20
Which exception is thrown when accessing a null object?
  • A NullException
  • B NullReferenceException
  • C ObjectNotFoundException
  • D NullObjectException
Answer: Option B
Explanation: NullReferenceException occurs on null object access.
Questions and Answers for Competitive Exams Various Entrance Test