C#.NET — Interfaces: choose the correct statement about members and implementation.

Difficulty: Easy

Correct Answer: Interface members are automatically public.

Explanation:


Introduction / Context:
This checks your understanding of interface contracts in C#.NET: what they contain, their accessibility, and how a class satisfies them.



Given Data / Assumptions:

  • “Inherit” for interfaces means a class implements an interface’s signatures, not concrete implementations.
  • Classic interface rules (no bodies) are assumed for exam purposes.


Concept / Approach:
Interface members are implicitly public and must be implemented with public members in the class. Interfaces can declare methods, properties, indexers, and events. Static is not required (and would be incorrect for instance contracts).



Step-by-Step Solution:

A — False: interfaces provide no implementations (again, per classic rules). B — False: interfaces may declare indexers (e.g., int this[int i] { get; }). C — True: interface members are public by definition. D — False: the implementing member must be public but not static.


Verification / Alternative check:
Attempt to implement an interface with a non-public member; the compiler requires public visibility.



Why Other Options Are Wrong:
They contradict core interface rules regarding member kinds and accessibility.



Common Pitfalls:
Equating interface “inheritance” with class inheritance; forgetting that interface contracts imply public accessibility.



Final Answer:
Interface members are automatically public.

More Questions from Interfaces

Discussion & Comments

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