Polymorphism in Action

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 1200+ tech skills courses.