Difficulty: Easy
Correct Answer: This is a perfectly workable interface.
Explanation:
Introduction / Context:Interfaces in C# define member signatures without implementation. This problem verifies whether properties and methods can be declared in an interface and whether bodies are required.
Given Data / Assumptions:
Concept / Approach:In classic C#, interface members have signatures only. Implementing types must provide bodies. Properties in an interface are declared with get; and/or set; accessors — again, without bodies. Methods (void or returning values) are allowed and, similarly, have no bodies in the interface.
Step-by-Step Solution:
Check properties FirstName/LastName → valid with get; set; signatures only.Check methods Print/Stock/Fun → valid method signatures; no bodies necessary.Therefore the interface compiles and is usable as a contract for implementing types.Verification / Alternative check:Create a class Employee : IPerson and implement each member. The compiler will require bodies in the class.
Why Other Options Are Wrong:
Common Pitfalls:Trying to put code into interface accessors or methods; implementation belongs in classes/structs that implement the interface.
Final Answer:This is a perfectly workable interface.
Discussion & Comments