DSA Factory
Free Object-oriented basics lessonsObject-oriented basics · Stage 2 · Inheritance and polymorphism · Step 3

Polymorphism and dynamic dispatch

How one call can run different code depending on the object, and the cases where it doesn't happen. About 14 minutes.

Quick check

Which is resolved by the variable's declared type rather than the object's real class?

  1. AReading a field
  2. BCalling an overridden instance method
  3. CCalling equals on the object
Show the answer

Reading a field. Fields aren't polymorphic.

Lock it in

4 questions on this idea

Short questions that apply the idea to new cases: trace it, work out a number, put steps in order. A wrong answer explains itself.

Answer them in your browserFree account, no card. Your progress is saved, and the idea comes back in a quick review later.
Sign up free to solve