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.
Which is resolved by the variable's declared type rather than the object's real class?
- AReading a field
- BCalling an overridden instance method
- CCalling equals on the object
Show the answer
Reading a field. Fields aren't polymorphic.
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