B3.2 Fundamentals of OOP for multiple classesB3.2.2

Polymorphism — Static (Method Overloading) and Dynamic (Method Overriding)

Construct code to model polymorphism and its various forms, such as method overriding

AHL≈ 60 minCommand term: ConstructPremium

In this lesson

  • Explaining polymorphism and how it makes code flexible and reusable
  • Constructing dynamic polymorphism with method overriding, including calling the superclass version
  • Applying static polymorphism with method overloading (and its Python equivalent)
  • Tracing which version of a method runs for objects in a superclass-typed list

This lesson is part of Premium

Every topic has one free lesson. Premium unlocks every interactive lesson, the exam-style questions at the end of each one, and the rest of Praxis IB.

What's inside

  1. LearnOne call, many forms
  2. CodeOverriding a method
  3. LabWhich version runs?
  4. LearnStatic polymorphism: overloading
  5. CodeOverloading in Java, a default parameter in Python
  6. LearnOverriding and overloading
  7. CheckOverriding or overloading?
  8. CheckQuick check
  9. ExamWorked exam answer
  10. ReviewMistakes examiners see
  11. Exam practiceExam-style questions

Ends with 4 exam-style questions worth 11 marks, with a self-marking markscheme.