Community resourceWorksheet

OCR H446 1.2.4 Inheritance, overriding and polymorphism

Part 8 of 10 · H446 1.2.4 · Types of programming language

Inheritance, overriding and polymorphism are examined together at H446 1.2.4 because they only make sense as one mechanism: a shared method name whose behaviour follows the actual type of the object. This worksheet traces that through an alert hierarchy, then asks students to design and explain their own.

Students will:

  • describe how a subclass reuses and specialises a superclass definition
  • identify what makes a loop calling one shared method name polymorphic
  • state which overridden implementation runs for each object in a mixed collection
  • write an OCR-style hierarchy with a superclass and two subclasses that override the same method
  • explain why unrelated method names give specialised behaviour without a common polymorphic interface

Inside: 5 explanation cells, 1 multiple-choice question, 2 fill-in-the-blanks cells and 3 written answers. 27 marks, about 40 to 50 minutes.

Series: H446 1.2.4 · Types of programming language, part 8 of 10.

Shared by Coding PathwayVerified teacher

  • 11 cells
  • About 45 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, overriding and polymorphism

Inheritance lets a subclass reuse and specialise a superclass definition. Overriding gives a subclass its own version of an inherited method. Polymorphism lets the same method call produce type-appropriate behaviour.

One interface, different behaviour

Inheritance, overriding and polymorphic behaviourAlertrecipient, message; send()EmailAlert inherits Alertoverrides send(): email routeScreenAlert inherits Alertoverrides send(): display routeThe same call alert.send() can run different overridden methods for different object types.That common interface with type-dependent behaviour is polymorphism.

EmailAlert and ScreenAlert inherit shared alert state. Each overrides send(). Code can work with a collection of Alert objects and call send() on each without a separate selection for every subtype. The object's actual type determines which overridden implementation runs.

OCR-style worked model

class Alert
    protected recipient
    protected message
    public procedure new(recipientIn, messageIn)
        recipient = recipientIn
        message = messageIn
    endprocedure
    public procedure send()
    endprocedure
endclass

class ScreenAlert inherits Alert
    public procedure new(recipientIn, messageIn)
        super.new(recipientIn, messageIn)
    endprocedure
    public procedure send()
        output('SCREEN:' + message)
    endprocedure
endclass

The subclass constructor calls super.new(...) to initialise inherited state. Its send() has the same interface but specialised behaviour.

Multiple choice1 mark

A list contains EmailAlert and ScreenAlert objects. The loop calls item.send() on each. What makes this polymorphic?

  • AThe same method call invokes the implementation for each object's type
  • BEvery object must print identical text
  • CThe loop converts objects to machine code
  • DEach subclass uses a different method name
Fill in the blanks3 marks
A subclass can gap 1 attributes and methods from a superclass. It can gap 2 a method with a specialised implementation. The same call producing type-dependent behaviour is gap 3.
  • inherit
  • override
  • polymorphism
  • encapsulation
Written answer6 marks

A collection contains EmailAlert('Mira','Ready'), ScreenAlert('Lab','Ready') and another ScreenAlert('Hall','Close'). A loop calls send() on each. State which implementation runs for each and explain why no type-selection chain is needed.

Use actual object type, overriding and common interface.

Students type their answer here.

Apply the model independently

The remaining tasks change the context or reduce the support. Complete them without copying the worked model, then check that each explanation connects a mechanism to its consequence.

Written answer10 marks

Design superclass Report with a title and method render(), then subclasses TextReport and ChartReport that override render(). Write coherent OCR-style pseudocode for the hierarchy and show a loop that calls the same method on one object of each subtype.

Use inheritance and the same method name/signature. Advanced overloading or multiple inheritance is not required.

Students type their answer here.

Written answer3 marks

Explain why defining sendEmail() and showOnScreen() as unrelated method names would demonstrate specialised behaviour but not the same polymorphic interface used in the model.

Compare the call sites and the need for type knowledge.

Students type their answer here.

Fill in the blanks4 marks
A subclass checkpoint gap 1 from a superclass. A replacement method with the same interface checkpoint gap 2 the inherited method. A call resolved to the object's actual type demonstrates checkpoint gap 3. super can invoke superclass 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 each consequence rather than only naming a feature.