Skip to content
UPEEC

Polymorphism in Java

A reference of a parent type can point to any subclass, and overridden methods run the subclass version.

Easy
Comments 0

List<Shape> shapes; for (Shape s : shapes) s.area(); — dynamic dispatch picks the right area().

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.