Community resourceWorksheet

OCR H446 2.2.1 Inheritance and polymorphism

Part 11 of 14 · H446 2.2.1 · Programming techniques

Not every relationship deserves inheritance, and H446 2.2.1 expects that test to be applied before a hierarchy is written. A digital exhibition with image and audio exhibits supplies shared identity and type-specific behaviour, so overriding and a single polymorphic call can be traced first and then built.

Students will:

  • test whether a relationship is genuinely is-a rather than containment
  • reuse the parent constructor when initialising a child class
  • override an inherited method so one common call gives type-specific results
  • predict the output of a loop over a mixed list of related objects
  • explain how the type of the object decides which method runs

Inside: 6 explanation cells, 2 multiple-choice questions, 1 fill-in-the-blanks cell, 1 written answer and 2 Python tasks. 17 marks, about 25 to 35 minutes.

Series: H446 2.2.1 · Programming techniques, part 11 of 14.

Shared by Coding PathwayVerified teacher

  • 12 cells
  • About 30 minutes
  • CC BY-SA 4.0
  • Shared 31 Aug 2026
  • Updated 3 Sept 2026

Preview

The whole resource, exactly as a class sees it. Answers and marking are held back.

Inheritance and polymorphism

A digital exhibition has image and audio exhibits with shared identity and type-specific descriptions.

By the end, you will be able to

  • test whether a relationship is genuinely is-a
  • reuse parent initialisation
  • override inherited behaviour
  • explain one common call producing type-specific results

Reactivate: classes, constructors and method calls.

Read the hierarchy before the code

Inheritance hierarchy and polymorphic method callExhibittitle; describe()ImageExhibitoverrides describe()AudioExhibitoverrides describe()item.describe() → implementation chosen from the runtime object type

Exhibit is the parent/superclass. ImageExhibit and AudioExhibit are child/subclasses. Each child is an Exhibit, inherits common state, and overrides describe(). A mixed collection can call describe() through one common interface; the runtime object type determines which implementation runs.

Inheritance is not the same as one object containing another: a child must genuinely be a specialised kind of its parent.

Worked hierarchy reasoning

AudioExhibit is an Exhibit, so inheritance is plausible. Exhibition has exhibits, so that relationship is containment, not inheritance.

When a mixed list loops over item.describe(), the call text is identical. Dynamic object type selects the parent or overridden child implementation. That is the polymorphic behaviour; an IF statement checking every type is not required.

Constructor plan: receive child data → call super for shared parent state → store child-only state.

Multiple choice1 mark

Which relationship is suitable for inheritance?

  • AExhibition has an Exhibit
  • BExhibit contains a title
  • CAudioExhibit is an Exhibit
  • DTitle calls a method
Worked example
class Exhibit:
    def __init__(self, title):
        self.title = title

    def describe(self):
        return self.title

class ImageExhibit(Exhibit):
    def __init__(self, title, pixels):
        super().__init__(title)
        self.pixels = pixels

    def describe(self):
        return self.title + " image"

items = [Exhibit("Map"), ImageExhibit("Sky", 800)]
for item in items:
    print(item.describe())
Written answer5 marks

Predict the two output lines from the supplied loop, then explain how the loop demonstrates polymorphism.

Give the outputs in order, identify the common call and link the selected method to runtime object type.

Students type their answer here.

Add an audio subclass

Implement AudioExhibit as a child of Exhibit. Its constructor must reuse the parent constructor and store duration. describe() returns title followed by ' audio ' and the duration.

Coding task6 marks
class Exhibit:
    def __init__(self, title):
        self.title = title

    def describe(self):
        return self.title

class AudioExhibit(Exhibit):
    pass
Multiple choice1 mark

What does overriding mean here?

  • ACreating two methods with different parameter counts in one class
  • BStoring an object inside another object
  • CUsing an if statement to inspect every type
  • DReplacing an inherited method with child-specific implementation

Checkpoint

Complete the inheritance-and-polymorphism explanation from memory. There is no answer bank, and correctness is withheld until teacher review.

Fill in the blanks4 marks
Inheritance represents an checkpoint gap 1 relationship. A child class checkpoint gap 2 members from its parent and may checkpoint gap 3 a method. Calling the same method on different object types to obtain type-appropriate behaviour is checkpoint gap 4.

Review your understanding

Before submitting, check that you can explain the main distinction in your own words, apply it in an unfamiliar context and justify the resulting behaviour or consequence.