Polymorphism in Action
Understand the relationship between a superclass and a subclass.
References using inheritance hierarchies
Superclass referenced as the superclass
The first case is pretty simple. When we instantiate a superclass object and store it in a variable of the superclass’s type, Java will call the method of the superclass.
Look at the code below.
Get hands-on with 1400+ tech skills courses.