C#.NET — Which of the following is NOT a valid .NET exception class?

Difficulty: Easy

Correct Answer: StackMemoryException

Explanation:


Introduction / Context:
The .NET Base Class Library defines many specific exception types. This question asks you to identify the option that does not correspond to an actual .NET exception class.



Given Data / Assumptions:

  • Common exceptions include Exception, DivideByZeroException, OutOfMemoryException, InvalidOperationException, and StackOverflowException.


Concept / Approach:
There is no type named StackMemoryException in the .NET BCL. The correct type for stack exhaustion is StackOverflowException. The other listed options are real, widely used exception classes in the System namespace hierarchy.



Step-by-Step Solution:

Check existence of each type in System.*:Exception → base class for all exceptions → exists.StackMemoryException → does not exist.DivideByZeroException → exists.OutOfMemoryException → exists.InvalidOperationException → exists.


Verification / Alternative check:
IntelliSense or reference docs show StackOverflowException as the correct class for stack exhaustion, not StackMemoryException.



Why Other Options Are Wrong:
They correspond to real exception types used by the CLR and libraries.



Common Pitfalls:
Memorizing slightly incorrect names (e.g., “StackMemory” vs. “StackOverflow”). The exact class name matters.



Final Answer:
StackMemoryException

More Questions from Exception Handling

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion