◈
Inheritance & Polymorphism
AP CSA · Unit 9: Inheritance
↺ Reset
⛶ Fullscreen
Hierarchy:
Animal
Classes:
4
Call:
—
Console Output
// Click "Call Method" to see output
Classes
4
Methods
—
Overrides
—
Depth
2
Dispatch
—
Example Hierarchy
Animal
Shape
Vehicle
Reference Type
Actual Object
Call Method
Demo
Polymorphic Array
Code
Quick Quiz
▼
1. If Dog extends Animal, and both have speak(), calling a.speak() on an Animal reference holding a Dog object runs:
Animal's speak()
Dog's speak()
Compilation error
Runtime error
2. The keyword to call a superclass constructor is:
this
super
parent
base
3. Polymorphism allows a single variable to refer to:
Only its declared type
Any subclass object of its type
Only static methods
Primitive types
Check Answers