📄 Paper 2 · 4.6 Hardware & Software
4.6.3a Object-Oriented Programming — Concepts
AQA 7517 · A-Level Computer Science · ~14 min read

What is Object-Oriented Programming?

OOP is a programming paradigm that organises software as a collection of objects. Each object combines data (attributes) and the operations that act on it (methods). OOP reflects real-world modelling and promotes reuse and modularity.

Classes and Objects

A class is a blueprint/template that defines what attributes and methods objects of that type will have. An object (or instance) is a specific realisation of a class in memory.

ConceptDefinitionExample
ClassBlueprint defining attributes and methodsclass Car:
Object/InstanceSpecific realisation of a classmyCar = Car()
AttributeData stored in an object (instance variable)myCar.colour = "red"
MethodFunction belonging to a classmyCar.start()
ConstructorSpecial method called when object is created (__init__)Sets initial attribute values

The Four Pillars of OOP

1. Encapsulation

Bundling data (attributes) and methods together inside a class, and restricting direct access to internal data from outside. Private attributes are only accessible via public methods (getters/setters).

  • Protects internal state from invalid external modification
  • Implementation details are hidden — the interface (public methods) is what's exposed
  • Also called information hiding

2. Inheritance

A subclass (child class) inherits attributes and methods from a superclass (parent class). The subclass can add new attributes/methods or override inherited ones. Enables code reuse.

  • Example: ElectricCar extends Car — inherits speed, colour, start(), and adds batteryLevel
  • Single inheritance: one parent class
  • Multiple inheritance: inherits from multiple parent classes (supported in Python)

3. Polymorphism

The same method name can behave differently depending on the object it is called on. Different classes can implement the same interface in their own way.

  • Example: speak() method — a Dog object returns "Woof", a Cat object returns "Meow"
  • Allows code that works with a superclass type to automatically work with all subclasses
  • Method overriding: subclass provides its own implementation of an inherited method

4. Abstraction

Hiding complex implementation details and exposing only what is necessary to the user. Users interact with a simplified interface without needing to understand internal mechanics.

  • Example: calling car.start() — you don't need to know how the ignition system works
  • Abstract classes cannot be instantiated directly — they define an interface for subclasses
Exam tip: Be able to define all four pillars — encapsulation, inheritance, polymorphism, abstraction. Know the difference between a class (blueprint) and an object (instance). Know what a constructor does. AQA may ask you to identify OOP concepts in code snippets or explain how a class hierarchy works with inheritance and polymorphism. Be precise with terminology — "instance" not just "copy".
Click through the slides at your own pace. Use arrow keys or click to advance.
Click slide or press arrow keys to navigate

Worksheet — 4.6.3a OOP Concepts

8 questions · instantly marked · AQA 7517 standard

Q1Explain the difference between a class and an object (instance). Give an example of each.[4]
✅ Mark scheme
Mark scheme
Class: a blueprint/template that defines the attributes and methods that all objects of that type will have [1]; example: class Car [1]. Object/instance: a specific realisation of a class created in memory with its own attribute values [1]; example: myCar = Car() where myCar is one specific car object [1].
Q2Define encapsulation and explain how it protects data in an OOP program.[3]
✅ Mark scheme
Mark scheme
Encapsulation: bundling data (attributes) and methods that operate on that data together in a class [1]; private attributes can only be accessed/modified via public methods (getters/setters) [1]; this prevents external code from directly changing internal state to invalid values — protecting data integrity [1].
Q3Explain inheritance using a class hierarchy of Vehicle → Car → ElectricCar. What does each subclass gain from its parent?[4]
✅ Mark scheme
Mark scheme
Inheritance: a subclass (child class) automatically receives all attributes and methods of its superclass (parent class) [1]; Car inherits from Vehicle — gains generic vehicle attributes (speed, make) and can add car-specific ones (numDoors) [1]; ElectricCar inherits from Car — gains all Vehicle and Car attributes, and adds battery-specific attributes (batteryLevel, chargingRate) [1]; this avoids code duplication and promotes reuse [1].
Q4Describe polymorphism and give a concrete example showing how it allows different objects to respond differently to the same method call.[3]
✅ Mark scheme
Mark scheme
Polymorphism: the same method name can behave differently depending on which object (class) it is called on [1]; example: Animal superclass has speak() method; Dog subclass overrides it to return "Woof"; Cat subclass overrides it to return "Meow" [1]; code can call speak() on any Animal object and get the appropriate response regardless of which specific subclass it is [1].
Q5What is a constructor and what is its purpose in a class?[2]
✅ Mark scheme
Mark scheme
A constructor is a special method (called __init__ in Python) that is automatically called when a new object of the class is created [1]; its purpose is to initialise the object's attributes to their starting values [1].
Q6Explain the principle of abstraction in OOP. Give an example of how abstraction benefits users of a class.[2]
✅ Mark scheme
Mark scheme
Abstraction: hiding complex implementation details and exposing only a simple interface to the user [1]; example: a user calls car.start() without needing to know how the engine initialisation, fuel injection, or ignition timing works internally [1].
Q7State two advantages of using OOP over procedural programming for a large software project.[2]
✅ Mark scheme
Mark scheme
Any two of: code reuse through inheritance reduces duplication [1]; encapsulation makes code modular and easier to maintain/debug [1]; easier to model real-world entities as objects [1]; polymorphism allows flexible, extensible code [1].
Q8In Python, a class BankAccount has a private attribute _balance. Explain why making it private is good OOP practice, and how external code should access or modify it.[3]
✅ Mark scheme
Mark scheme
Making _balance private implements encapsulation — prevents external code from directly setting an invalid balance (e.g. negative) [1]; external code should use public methods: a getter (e.g. get_balance()) to read the balance [1]; and a setter or deposit/withdraw methods that include validation before changing the value [1].
Topic Quiz
Question 1 of 15
You scored
out of 15
Card 1 of 10
Click to reveal definition
🎉
All cards reviewed!
TermDefinition
🎯

Mini Test — OOP Concepts

10 questions · 10 minutes

← 4.6.2 Programming Languages
47 of 70 · AQA 7517
4.6.3b OOP in Practice →