Lecture 9: Object Oriented Design: Interfaces and Abstract Classes
lecture audio (thought I was recording video in higher quality…instead, just didn’t record video)
Textbook section
2.3
Interfaces
In general:
- We don’t need to know what’s going on underneath the hood! We just need the interface to be specified.
In Java:
- An interface is a collection of method declarations with no data and no bodies.
- Interfaces have no constructors and they cannot be directly instantiated.
- A class then implements an interface.
Abstract classes
- In between an interface and a normal (concrete) class
- Example: we can implement
Animal
as an abstract class, whileTortoise
,Otter
, andSlowLoris
inherit from and implement its abstract methods.