C#.NET — Which statement about interfaces is correct?

Difficulty: Easy

Correct Answer: Properties can be declared inside an interface.

Explanation:


Introduction / Context:
This item checks fundamental truths about C# interfaces: multiple implementation, interface inheritance, and the kinds of members interfaces can declare.



Given Data / Assumptions:

  • C# allows a class or struct to implement multiple interfaces.
  • Interfaces can inherit from multiple interfaces.
  • Interfaces can declare properties, methods, events, and indexers.


Concept / Approach:
Eliminate false claims: single-interface-only implementation is false; exclusivity of implementation to a single class is false; prohibition on multiple base interfaces is false; and “interfaces cannot be inherited” is false. The remaining positive fact is that properties are allowed inside interfaces.



Step-by-Step Solution:

Reject A: Classes may implement many interfaces.Reject B: Any number of classes can implement the same interface.Reject C: New interfaces may inherit multiple base interfaces.Accept D: Properties are valid interface members.Reject E: Interfaces can inherit other interfaces.


Verification / Alternative check:
Write interface IX { int P { get; set; } } and interface IY : IX, IDisposable { }. Implement both in various classes; compilation succeeds.



Why Other Options Are Wrong:
They contradict the multiple-interface implementation/inheritance features of C#.



Common Pitfalls:
Confusing class single inheritance (only one base class) with interface multiple inheritance (many interfaces).



Final Answer:
Properties can be declared inside an interface.

Discussion & Comments

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