Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.

Instruction

Inheritance basics

is-a vs has-a relationships

Classes are related to each other. An is-a relationship exists between a subclass and a superclass.

Example: A daffodil is a plant. A Daffodil class inherits from a superclass, Plant.

Is-a relationships can be confused with has-a relationships. A has-a relationship exists between a class that contains another class.

Example: An ...