Absract Classes and Interfaces Flashcards
1
Q
What is an abstract class?
A
An abstract class is:
- A special type of class that cannot be instantiated.
- It contains at least 1 abstract method and can contain concrete methods.
- It is “contract-based”. Abstract methods MUST be overridden in the subclass.
2
Q
What is an interface?
A
An interface is:
- A special type of class that cannot be instantiated
- It specifies what a class does, but not how it implements it.
- It lacks instance variables.
- It is characterized by behavior.
3
Q
How is inheritance between classes and interfaces?
A
Classes can inherit interfaces; from 0 to many.
4
Q
How is inheritance between an interface to another interface?
A
Interfaces can extend other interfaces; from 0 to many.