Difficulty: Easy
Correct Answer: 1, 2, 4
Explanation:
Introduction / Context:
C# interfaces specify contracts. Knowing which members are allowed within an interface definition is essential for proper API design.
Given Data / Assumptions:
Concept / Approach:
Interfaces can declare members that describe behavior: methods, properties, events, and indexers. They do not declare fields. Type declarations (enums, structs, classes) are not declared inside an interface in classic C# usage for this curriculum.
Step-by-Step Solution:
Verification / Alternative check:
Write a small interface: interface IEx { int P { get; set; } event EventHandler E; void Do(); } — compiles. Attempt to place a nested enum or struct in the interface and note it is outside the scope of this syllabus and not used for typical design.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing interface members (behavioral contracts) with type definitions, which belong at the namespace or type level, not inside an interface for this exam.
Final Answer:
1, 2, 4
Discussion & Comments