Skip to main content
PProfileMatch
← Path

Object-Oriented Programming · Polymorphism, Abstraction and Interfaces in OOP (Java Examples)

0 XP
  1. 1 current stop: learning
  2. 2 upcoming
  3. 3 upcoming
  4. 4 upcoming
  5. 5 upcoming

Finish after stop 5

Stop 1 of 5 · Restaurant: ordering from the menu

Trick to keep in mind+3 XP

The declared type picks the menu; the real object cooks the dish.

With Shape s = new Circle(), the variable's type decides which methods the compiler lets you call. When an instance method actually runs, the JVM checks the real class of the object and uses that class's version. This run-time lookup is dynamic dispatch, and it lets one call site serve many implementations.

Read it once, then a question tests whether the trick stuck.