OOP principle: encapsulation
Bundling an object's data and methods together and restricting access, so private data is only changed through public methods that can check values are valid.
Understanding OOP principle: encapsulation in VCE Software Development U3O1
What it does: The method tests the value first, so only a valid amount can update the private attribute. Calling a public method uses the interface, which keeps the data safe, instead of writing account._balance = 50 directly. Encapsulation keeps an object's data and the methods that use it together, and controls how the data is accessed. A leading underscore is the Python convention for 'private - use the class's methods instead of touching this directly'. The class designer writes the validation in a method. Python will not do it unless that check is coded. A setter should validate first, so an invalid age such as -5 is never stored.
Common mistakes: Without self. this makes a local variable that disappears when __init__ ends. The data is not stored in the object. It should be self._balance = 0. Every method in a class needs self as its first parameter so it can reach the object's private data. It should be def set_mark(self, m):.
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 125–141) and word search (Modules 114–141).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
encapsulationFill in the Blanks
Spot the Error
Student with a class code? Join your class →