Track progress, take quizzes and save notes on this lesson.

Free forever · no card needed

Start free
Intermediate

Object-Oriented Programming

4.1.3 Programming paradigms: OOP — classes, objects, encapsulation, inheritance, polymorphism, class diagrams

Aligned to the AQA 7517 specification

Level
Intermediate
Reading time
6 min
Published
13 June 2026
Updated
1 July 2026
On this page
  1. 1.Procedural vs Object-Oriented Programming
  2. 2.Classes and Objects
  3. 3.Encapsulation
  4. 4.Inheritance
  5. 5.Polymorphism and Class Diagrams
  6. 6.Advantages of OOP
  7. 7.Common Exam Mistakes

Key takeaways

  • A class is a blueprint defining the structure and behaviour of a category of objects, while an object is a specific instance with its own copies of the class's attributes.
  • Encapsulation bundles attributes and methods inside a class with controlled access, so external code reaches private data only through getter and setter methods, protecting it from uncontrolled modification.
  • Inheritance lets a subclass inherit the attributes and methods of a superclass and add or override them, enabling code reuse across related classes.
  • Polymorphism means the same method call on objects of different types sharing a superclass executes different code depending on the object's actual type at runtime, not merely sharing a method name.
  • PRIVATE attributes are accessible only within the declaring class, whereas PROTECTED attributes are also accessible within any subclass; a subclass cannot directly access a superclass's PRIVATE attribute.

Procedural vs Object-Oriented Programming

Procedural programming structures code as a sequence of procedures that operate on data. Data and the code that manipulates it are kept separate.

Object-oriented programming (OOP) bundles data (attributes) and the procedures that operate on it (methods) together into objects. Programs are modelled as interactions between objects.

AspectProceduralObject-Oriented
OrganisationProcedures and data separateData and methods bundled in objects
ReuseVia procedure callsVia inheritance and composition
StateGlobal or passed as parametersEncapsulated inside objects
Best forSimple, sequential tasksComplex systems with many interacting entities

Classes and Objects

A class is a blueprint that defines the structure and behaviour of a category of objects.

An object is a specific instance of a class — it has its own copies of the attributes defined in the class.

CLASS Animal
    PRIVATE name : STRING
    PRIVATE sound : STRING

    PUBLIC PROCEDURE new(aName, aSound)
        name ← aName
        sound ← aSound
    ENDPROCEDURE

    PUBLIC FUNCTION speak()
        RETURN name + " says " + sound
    ENDFUNCTION
ENDCLASS

dog ← NEW Animal("Dog", "Woof")
cat ← NEW Animal("Cat", "Meow")
OUTPUT dog.speak()    // Dog says Woof
OUTPUT cat.speak()    // Cat says Meow

dog and cat are two distinct instances of the Animal class. Each has its own name and sound attribute values.

Encapsulation

Encapsulation is the bundling of data (attributes) and the methods that operate on it inside a class, with controlled external access.

  • Private attributes/methods: accessible only from within the class
  • Public attributes/methods: accessible from outside the class

Encapsulation protects data from uncontrolled modification. External code accesses private data only through getter (accessor) and setter (mutator) methods:

CLASS BankAccount
    PRIVATE balance : REAL

    PUBLIC PROCEDURE new(initialBalance)
        balance ← initialBalance
    ENDPROCEDURE

    PUBLIC FUNCTION getBalance()
        RETURN balance
    ENDFUNCTION

    PUBLIC PROCEDURE deposit(amount)
        IF amount > 0 THEN
            balance ← balance + amount
        ENDIF
    ENDPROCEDURE
ENDCLASS

Encapsulation prevents external code from setting balance to a negative value directly. The deposit method enforces the business rule that deposits must be positive.

Inheritance

Inheritance allows a class (the subclass or child class) to inherit the attributes and methods of another class (the superclass or parent class), and add or override them.

CLASS Shape
    PROTECTED colour : STRING

    PUBLIC FUNCTION getColour()
        RETURN colour
    ENDFUNCTION

    PUBLIC FUNCTION area()
        RETURN 0        // Default — overridden in subclasses
    ENDFUNCTION
ENDCLASS

CLASS Rectangle INHERITS Shape
    PRIVATE width : REAL
    PRIVATE height : REAL

    PUBLIC PROCEDURE new(w, h, c)
        width ← w
        height ← h
        colour ← c
    ENDPROCEDURE

    PUBLIC FUNCTION area()
        RETURN width * height    // Overrides Shape.area()
    ENDFUNCTION
ENDCLASS

r ← NEW Rectangle(5, 3, "red")
OUTPUT r.area()         // 15
OUTPUT r.getColour()    // red (inherited from Shape)

The Rectangle class inherits getColour() from Shape and overrides area() with its own implementation.

Worth saving these ideas?

Turn what you've read into instant revision cards. Free to get started.

Make flashcards

Polymorphism and Class Diagrams

Polymorphism means "many forms" — a method with the same name can behave differently depending on the object it is called on.

CLASS Circle INHERITS Shape
    PRIVATE radius : REAL
    ...
    PUBLIC FUNCTION area()
        RETURN 3.14159 * radius * radius  // Different from Rectangle.area()
    ENDFUNCTION
ENDCLASS

Both Rectangle and Circle have an area() method, but each computes it differently. Code that holds a list of Shape objects can call area() on each without knowing whether it is a Rectangle or Circle.

Class diagram notation shows the structure of classes and their relationships:

  • - prefix: private attribute/method
  • + prefix: public attribute/method
  • Arrow from subclass to superclass: inheritance relationship

Advantages of OOP

OOP is widely used for complex software systems because:

AdvantageExplanation
EncapsulationHides internal implementation; reduces unintended interference between components
InheritanceReuse code across related classes; extend existing classes without modifying them
PolymorphismWrite generic code that works with any subclass; easier to add new types
ModularityEach class is an independent unit; easier to develop, test, and maintain
ReusabilityClasses can be imported into new projects as libraries

Common Exam Mistakes

1. Confusing a class and an object

A class is the blueprint; an object is an instance created from the blueprint. You can have many objects from one class, each with different attribute values.

2. Forgetting NEW when creating an object

dog ← Animal("Dog") is wrong in AQA pseudocode. Instantiation requires NEW: dog ← NEW Animal("Dog").

3. Treating PROTECTED and PRIVATE as identical

PRIVATE attributes are accessible only within the declaring class. PROTECTED attributes are accessible within the declaring class and any subclass. A PRIVATE attribute in a superclass is not directly accessible in a subclass — the subclass must use getters.

4. Describing polymorphism incorrectly

Polymorphism is not simply "different classes having methods with the same name." It is that the same method call on objects of different types (sharing a superclass) executes different code depending on the actual type of the object at runtime.

Key terms

Procedural programming
A paradigm that structures code as a sequence of procedures operating on data, keeping data and the code that manipulates it separate.
Object-oriented programming (OOP)
A paradigm that bundles data (attributes) and the procedures that operate on it (methods) together into objects, modelling programs as interactions between objects.
Class
A blueprint that defines the structure and behaviour of a category of objects.
Object
A specific instance of a class, with its own copies of the attributes defined in the class.
Encapsulation
The bundling of attributes and the methods that operate on them inside a class, with controlled external access through public and private members.
Getter and setter
Accessor (getter) and mutator (setter) methods through which external code reads or changes private attributes in a controlled way.
Inheritance
A mechanism allowing a subclass to inherit the attributes and methods of a superclass and add to or override them.
Polymorphism
The property where the same method call on objects of different types sharing a superclass executes different code depending on the object's actual type at runtime.
PRIVATE
An access level making an attribute or method accessible only from within the declaring class.
PROTECTED
An access level making an attribute or method accessible within the declaring class and any subclass.
Instantiation
Creating an object from a class, which in AQA pseudocode requires the NEW keyword, e.g. dog ← NEW Animal("Dog").

Frequently asked questions

A class is the blueprint that defines the structure and behaviour of a category of objects, while an object is a specific instance created from that blueprint. You can create many objects from one class, each with its own attribute values.

PRIVATE attributes are accessible only within the declaring class, while PROTECTED attributes are accessible within the declaring class and any subclass. A PRIVATE attribute in a superclass is not directly accessible in a subclass, which must use getters instead.

Polymorphism means many forms: the same method call on objects of different types that share a superclass executes different code depending on the object's actual type at runtime. It is not simply different classes having methods with the same name.

Generate revision on any topic you study

Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.

Lessons on anything

Structured, level-matched lessons on any topic you study

Practice quizzes

Find out what you actually know before the exam does

Flashcard sets

Lock in key concepts with instant revision cards

Ask Aica

Stuck on something? Get a clear explanation, any time

Prev

Subroutines and Recursion

Next

Arrays and Abstract Data Types

Related lessons

7 min

6 min

Top students don’t revise more. They revise what counts.

Start revising free

Free to start. No card needed.