Inheritance
April 8th, 2016
Lecture Code
Extra Slides
Inheritance: Key Ideas
- Terminology: superclass, subclass
- public class A extends otherClassName
- super(params);
- Every class is automatically a subclass or descendant of the
Object class. The object class has some useful built-in
methods should as toString() and clone().
Class Exercise
Develop classes to represent the following concepts and
then write a driver program to illustrate their use.
- Bird.
- Magpie. Magpies are birds. Magpies can fly.
Adult magpies weight 225 grams on average.
- Ostrich. Ostriches are birds. Ostriches can not fly.
Adult ostriches weigh 100 kilograms on average.
- Bald Eagle. Bald Eagles are birds. Bald Eagles can fly.
Adult bald eagles weigh 4 kilograms on average.