← VCE Software Development U3O1

OOP principle: inheritance

Inheritance: the child (sub) class reuses the parent (super) class's attributes and methods and can add or change its own, showing an is-a relationship.

Understanding OOP principle: inheritance in VCE Software Development U3O1

What it does: The child class name comes first and the parent class goes in brackets, which models the is-a relationship. Dog has no eat() method of its own, so the call works only because Dog inherits eat() from its parent, which avoids rewriting it. Inheritance models an 'is-a' relationship. A Dog is a kind of Animal, so Dog can inherit from Animal. A Student is a Person (is-a). A Car has wheels (has-a), so inheritance does not suit Car and Wheel.

Common mistakes: A parent class is created with the class keyword, not def. It should be 'class Animal:' so that Dog can inherit from it. The parent class name in brackets must match exactly. Python is case sensitive, so 'shape' is undefined. It should be 'class Circle(Shape):'.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 142–155) and word search (Modules 142–166).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which line makes Dog a child class of Animal?
class Dog(Animal):class Animal(Dog):
Matches
class Animal(Dog):
↓
The parent and child are the wrong way round. Dog is an Animal, so Dog should be the child: class Dog(Animal):
Applying
Meanings
Term
class Child(Parent):
Meaning
Inheritance: the child (sub) class reuses the parent (super) class's attributes and methods and can add or change its own, showing an is-a relationship.
Practice
class Animal:
Testing
Gaps
class Dog():
Check Answer
Spots
1def Animal:
2 def eat(self):

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Cheetah' badge — Savannah Sprinter, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which line makes Dog a child class of Animal?
A. class Dog(Animal): ✓
B. class Animal(Dog):
The parent class goes in brackets after the child's name. class Dog(Animal): means Dog inherits from Animal.
2. Which statement describes the relationship that inheritance shows?
A. Has-a: a Dog is an Animal
B. Is-a: a Dog is an Animal ✓
Inheritance models an 'is-a' relationship. A Dog is a kind of Animal, so Dog can inherit from Animal.
3. A child class is created from Parent. What does the child get automatically?
A. The parent's attributes and methods ✓
B. Only the parent's class name
A child class reuses the parent's attributes and methods, so you do not have to rewrite that code.
4. Which pair is a good fit for inheritance?
A. Student inherits from Person ✓
B. Car inherits from Wheel
A Student is a Person (is-a). A Car has wheels (has-a), so inheritance does not suit Car and Wheel.
5. Which is the parent (super) class in: class Cat(Pet):
A. Cat
B. Pet ✓
The class in the brackets is the parent (super) class. Cat is the child (sub) class.

Match the Pairs

class Dog(Animal): → Dog is a child (sub) class that inherits the attributes and methods of the parent class Animal
class Car(Vehicle): pass → Car reuses everything from Vehicle without writing any new code, because a Car is a Vehicle
Is-a relationship: a Student is a kind of Person, so Student is the child class → class Student(Person):
Reuse of code: a child object can call a method written only in the parent class → pet = Dog() pet.eat()
class Animal(Dog): → The parent and child are the wrong way round. Dog is an Animal, so Dog should be the child: class Dog(Animal):
class Teacher inherits Person: → Python has no inherits keyword. The parent class must go in brackets: class Teacher(Person):

Key Term

class Child(Parent):
Inheritance: the child (sub) class reuses the parent (super) class's attributes and methods and can add or change its own, showing an is-a relationship.

Fill in the Blanks

1. class Animal: pass class Dog(Animal):
Hint: Type the name of the parent (super) class that Dog inherits from
2. class Bird(Animal): def speak(self): print("Tweet")
Hint: Type the keyword that defines a method, here overriding the parent's version
3. rex = Dog() print(isinstance(rex, Animal))
Hint: Type the built-in function that checks an is-a relationship between an object and a class
4. class Dog(Animal): pass print(issubclass(Dog, Animal))
Hint: Type the built-in function that checks whether one class inherits from another
5. class Animal: pass class Dog(Animal): pass class Puppy(Dog): pass
Hint: Type the parent class, because a Puppy is a kind of this class

Spot the Error

Question 1
A def Animal:
B def eat(self):
C print('Eating')
D class Dog(Animal):
E pass
F Dog().eat()
Line A — A parent class is created with the class keyword, not def. It should be 'class Animal:' so that Dog can inherit from it.
Question 2
A class Shape:
B sides = 0
C class Circle(shape):
D round = True
E print(Circle.sides)
Line C — The parent class name in brackets must match exactly. Python is case sensitive, so 'shape' is undefined. It should be 'class Circle(Shape):'.
Question 3
A class Animal:
B def eat():
C print('Eating')
D class Cat(Animal):
E pass
F Cat().eat()
Line B — Methods in the parent class need self as the first parameter. Without it the inherited method fails when the child object calls it. It should be 'def eat(self):'.
Question 4
A class Staff:
B def _init_(self, name):
C self.name = name
D class Teacher(Staff):
E pass
F t = Teacher('Ms Lee')
Line B — The constructor needs double underscores on both sides: __init__. With _init_ it is just an ordinary method, so Teacher inherits no constructor. It should be 'def __init__(self, name):'.
Question 5
A class Animal:
B legs = 4
C class Bird extends Animal:
D legs = 2
E print(Bird.legs)
Line C — Python does not use 'extends'. A child class names its parent in brackets: 'class Bird(Animal):'.

Student with a class code? Join your class →