Recall & Review
beginner
What is an interface in C#?
An interface is a contract that defines a set of methods and properties without implementation. Classes or structs that implement the interface must provide the implementation.
Click to reveal answer
beginner
What is an abstract class in C#?An abstract class can have both implemented and unimplemented methods. It cannot be instantiated directly and is meant to be a base class for other classes.Click to reveal answer
intermediate
When should you choose an interface over an abstract class?
Choose an interface when you want to define a contract for unrelated classes or when multiple inheritance of behavior is needed, since a class can implement multiple interfaces.Click to reveal answer
intermediate
When is an abstract class a better choice than an interface?Use an abstract class when you want to share common code among closely related classes and provide some default behavior along with abstract methods.Click to reveal answer
beginner
Can a class implement multiple interfaces or inherit multiple abstract classes in C#?A class can implement multiple interfaces but can inherit only one abstract class.Click to reveal answer
Which of the following can a C# class inherit from multiple times?
✗ Incorrect
In C#, a class can implement multiple interfaces but can inherit only one abstract or concrete class.
What is a key difference between an interface and an abstract class?
✗ Incorrect
Abstract classes can have implemented methods and fields, while interfaces cannot have fields and traditionally had no implementations (though default interface methods exist in newer C# versions).
When would you prefer an abstract class over an interface?
✗ Incorrect
Abstract classes allow sharing common code and default behavior among related classes.
Can interfaces contain fields in C#?
✗ Incorrect
Interfaces cannot contain fields; they only declare methods, properties, events, or indexers.
Which statement is true about abstract classes?
✗ Incorrect
Abstract classes can have both abstract methods (without implementation) and concrete methods (with implementation).
Explain the main differences between interfaces and abstract classes in C# and when to use each.
Think about code sharing and inheritance rules.
You got /5 concepts.
Describe a real-life scenario where choosing an interface is better than an abstract class.
Consider when different objects share capabilities but not implementation.
You got /4 concepts.