Lecture 2
Lecture 2
Lecture 2
Type Hierarchy (2)
Data abstraction
What is data abstraction?
Vehicle's
Bus's further
restriction restriction
on weight on weight
(inherited)
Example: Car's restriction on weight
Vehicle's
Car's further
restriction restriction
on weight on weight
(inherited)
Specify overriding methods
Method to be overridden:
getInstance(): Vehicle
Overriding method:
getInstance(): Car
Reason for compatibility:
Car is a subtype of Vehicle
Methods rule