Programming Flashcards
Define : Interface
Defines the things that something makes available to the outside world.
Members of an interface are implicitly
public and abstract, and are required to be so.
How class indicates that it implements an interface (code example)
public class AwesomeClass : InterfaceName { implementation of methods}
You can implement multiple interfaces at the same time
True
You can implement interfaces and declare a base class at the same time
True
How interface is defined (code example)
public interface InterfaceName { members }
A class that implements an interface does not have to provide implementation for all of the members of the class
False
A class that implements an interface is allowed to have other members that aren’t defined in the interface
True
A class can have more than one base class
False
Define : Polymorphism
You can create derived classes that implement the same method in different ways
How to implement polymorphism in the base class
mark the method as ‘virtual’
How to implement polymorphism in a derived class
mark it ‘override’ and provide alternative implementation
How to prevent creation of instance from base class
mark the class as ‘abstract’
How to force derived classes to implement methods that don’t exist in base class
In the base class create an empty method marked as abstract
New keyword attached to a method means?
A new method is being created unrelated to any methods in the base class. This is not great.