Difficulty: Easy
Correct Answer: 1, 3, 4
Explanation:
Introduction / Context:
This question validates knowledge of where enums can be declared and which underlying numeric types are allowed in C#.NET.
Given Data / Assumptions (Statements):
Concept / Approach:
Enums can be declared at namespace scope or nested inside classes/structs. Underlying types must be integral: byte, sbyte, short, ushort, int, uint, long, or ulong. Floating-point and decimal are not allowed. Enum variables must hold values of that enum’s underlying integral domain, not arbitrary object references.
Step-by-Step Evaluation:
object
cannot be directly assigned to an enum variable.
Verification / Alternative check:
Declare test enums with : byte
or : long
to confirm valid underlying types. Attempting : float
or : decimal
results in a compile error.
Why Other Options Are Wrong:
Any choice including statement 2 or 5 is invalid due to incorrect typing rules for enums.
Common Pitfalls:
Assuming any numeric type works; only integral types are valid. Also, forgetting that nested enums default to member accessibility rules of the containing type.
Final Answer:
1, 3, 4
Discussion & Comments