Suppose we have a general class Animal and a more specific class Dog that extends Animal. Because a Dog “is an” Animal, you can store a Dog object in an Animal variable. This lets you write code in terms of the general Animal type while at runtime the Dog’s behavior runs—this is polymorphism. We will explore this in more detail in 9.6.
Back to Inheritance (NOT REQUIRED)
Lesson PreviewLesson 5 of 7 in this unit
9.5 EXTRA: Creating References Using Inheritance Hierarchies
Part of Inheritance (NOT REQUIRED) in AP® Computer Science A. Read the opening section, then create a free account for the full interactive lesson, practice, and progress tracking.
In this unit
7 lessons
- 9.1EXTRA: Creating Superclasses and SubclassesPreview lesson
- 9.2EXTRA: Writing Constructors for SubclassesPreview lesson
- 9.3EXTRA: Overriding MethodsPreview lesson
- 9.4EXTRA: super KeywordPreview lesson
- 9.5EXTRA: Creating References Using Inheritance HierarchiesThis lesson
- 9.6EXTRA: PolymorphismPreview lesson
- 9.7EXTRA: object SuperclassPreview lesson
Continue the full lesson in Stellar
Create a free account to unlock the remaining sections, checkpoints, course practice, and progress tracking for AP® Computer Science A.