Bird
0
0

Which of the following is the correct syntax to catch a specific exception type ArgumentNullException in C#?

easy📝 Syntax Q12 of 15
C Sharp (C#) - Exception Handling
Which of the following is the correct syntax to catch a specific exception type ArgumentNullException in C#?
Acatch (ArgumentNullException e) { }
Bcatch ArgumentNullException (e) { }
Ccatch (Exception e) { }
Dcatch ArgumentNullException { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall catch block syntax

    In C#, to catch a specific exception, use catch (ExceptionType variable) syntax.
  2. Step 2: Match the correct syntax for ArgumentNullException

    The correct syntax is catch (ArgumentNullException e) { }, which declares the exception type and variable.
  3. Final Answer:

    catch (ArgumentNullException e) { } -> Option A
  4. Quick Check:

    Correct catch syntax = catch (ExceptionType e) [OK]
Quick Trick: Use parentheses around exception type and variable in catch [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses around exception type
  • Using wrong order like catch ExceptionType (e)
  • Not declaring a variable for the exception

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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