Polymorphism

Java polymorphism: how the runtime object chooses which overridden method runs, what the declared type decides, hiding, casts and instanceof.

  • 9 cards
  • 5 questions
  • About 10 min
  • Intermediate to Advanced
Share

Polymorphism: one method call that runs different code depending on the object behind it. It rests on a single prediction worth getting right: given a variable of one type holding an object of another, which body of code runs. It covers the rule that picks the body, two surface-different examples, what the compiler checks against what the JVM chooses, fields that hide rather than override, casts that throw, and when a chain of instanceof is the better shape. It leaves out generic methods, which belong to Java Collections and Streams.

Contents

9 cardsnot started