~/ 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/8fa37489-d406-4464-b339-c068afe9014a/flashcard utf-8 LF