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.

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.

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.