~/ learn/ java-from-zero/ cards/ Polymorphism & dynamic dispatch
1 of 4

Type a polymorphic assignment and call

Type a polymorphic assignment and call

Answer

Shape s = new Circle(); System.out.println(s.describe());

s is declared as Shape but holds a Circle. The call to describe() dispatches to Circle.describe() at runtime — that is polymorphism. The reference type governs what methods are visible; the object type governs which body runs.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/73c99b6d-7e11-4548-89f4-9996c1c2a0d1/flashcard utf-8 LF