Recall & Review
beginner
What does multiple interface implementation mean in C#?
It means a class can use more than one interface at the same time, allowing it to promise to do multiple sets of actions.Click to reveal answer
beginner
How do you declare a class that implements two interfaces named <code>IWalk</code> and <code>IRun</code>?Use a comma to separate interfaces like this:<br><pre>class Animal : IWalk, IRun { }</pre>Click to reveal answer
intermediate
Can a class implement two interfaces that have methods with the same name?Yes, but you may need to use explicit interface implementation to avoid confusion and specify which method belongs to which interface.
Click to reveal answer
intermediate
What is explicit interface implementation in multiple interface implementation?
It is a way to write methods so they only work when accessed through the interface, helping to handle method name conflicts.
Click to reveal answer
beginner
Why is multiple interface implementation useful?
It helps a class to follow many different contracts or roles, making code flexible and easier to organize.Click to reveal answer
How do you declare a class that implements two interfaces
IRead and IWrite?✗ Incorrect
In C#, use a colon and separate interfaces with commas:
class File : IRead, IWrite { }.If two interfaces have a method with the same name, how can a class implement both?
✗ Incorrect
Explicit interface implementation lets you specify which method belongs to which interface.
Which keyword is used to implement interfaces in a class?
✗ Incorrect
C# uses a colon (:) to implement interfaces in a class.
Can a class implement zero or more interfaces?
✗ Incorrect
A class can implement no interfaces or many interfaces.
What happens if a class implements an interface but does not provide all methods?
✗ Incorrect
C# requires all interface methods to be implemented, or the code will not compile.
Explain how multiple interface implementation works in C# and why it is useful.
Think about how a class can promise to do many things by following many contracts.
You got /4 concepts.
Describe explicit interface implementation and when you would use it.
Consider when two interfaces have the same method name.
You got /4 concepts.