Polymorphism and overriding – OCR A Level Computer Science lesson (H446)
Students learn to override a superclass method and explain how polymorphism lets one piece of code work with objects of different classes.
Lesson 7 of 13 in unit 12.6 Object-Oriented Programming, taught in Year 12, Spring 1. It answers one big question: How can one method call behave differently for each object?
By the end, students can override a superclass method and explain how polymorphism lets one piece of code work with objects of different classes.
- The Build (the main task)
- Write an overriding describe() method in Fernhollow's Bird and Reptile classes, and a loop that calls describe() on every animal in a list, then explain why this is polymorphism (6 marks).
- Support version
- Animal.describe() given as a model, with the Bird version's header written; students complete Bird, then Reptile, and finish the explanation from a sentence starter.
- Challenge
- Use super to make Bird's describe() add to the Animal version instead of replacing it.
- Real-world link
- The information screens at Fernhollow's entrance show a different description for each kind of animal.
- Key words
- Polymorphism, Overriding and Adapt, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “Polymorphism is the same as inheritance”; “Overriding deletes the superclass's method”.
- OCR H446 specification
- 1.2.4 (e); 2.2.1 (f) (programming techniques: using object-oriented techniques when writing programs).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Students need computers for the main task.
Also sold in the Object-Oriented Programming unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
An independent resource written for OCR A Level Computer Science (H446). It is not endorsed by OCR or Cambridge University Press & Assessment. Programming project (NEA) lessons teach general skills on a made-up example project and give supervised time, within JCQ's rules on the help a centre may give.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
More for A Level Computer Science
See allStudents learn to describe the characteristics of procedural and object-oriented languages and explain why different paradigms exist.
Free sample lessonStudents learn to explain the difference between a class and an object, and create several objects from a given class.
Students learn to write a constructor that sets attributes from parameters, and instantiate objects correctly in Python and OCR pseudocode.
Written for the specifications named. Not endorsed by or affiliated with any exam board.