Object-Oriented Programming Concepts (OCR A-Level CS 1.2.4)

OCR A-Level CS 1.2.4: classes, objects, methods, attributes, encapsulation, inheritance and polymorphism, with class-writing in OCR pseudocode. Exam tips.


Free OOP Concepts revision resources (OCR A-Level Computer Science, 1.2.4)

We’ve made exam-style practice for this exact topic, free to download: OOP Concepts question sheet, mark scheme and cheat sheet. Grab them, have a go, then read the full guide below.

Object-oriented programming is one of the most heavily examined topics on Paper 1 — from one-mark "identify an attribute" questions right up to writing whole class definitions and a 12-mark discussion of OOP versus procedural programming. Spec point 1.2.4(e) (full A-level) covers classes, objects, methods, attributes, encapsulation, inheritance and polymorphism.

This guide explains each concept and shows you how to write classes in OCR pseudocode, the exact skill the exam tests.

[IMAGE: class-object.png — A class shown as a blueprint with attributes and methods, and two objects created from it as instances with their own attribute values.]

What is a class and what is an object?

A class is a blueprint (template) that defines a type of thing: its attributes (the data each one holds) and its methods (the things it can do). An object is an instance of a class — one actual thing created from the blueprint, with its own attribute values.

One Dog class can create many dog objects: same structure, different data.

Worked example: writing a class in OCR pseudocode




Create an object with: myDog = new Dog("Rex", 3)

The pieces examiners look for: private attributes, a constructor (new) that sets them, and public get/set methods to access them — which leads straight to encapsulation.

What is encapsulation?

Encapsulation means keeping an object's attributes private, so they can only be read or changed through the class's public methods (get and set). The benefit: the class controls its own data — in the example above, setAge refuses a negative age, so no outside code can put the object into an invalid state. Encapsulation also means the internal implementation can change without breaking code that uses the class.

What is inheritance?

[IMAGE: inheritance-polymorphism.png — A Dog superclass with a Puppy subclass that inherits its attributes and methods, adds its own, and overrides one method to behave differently.]

Inheritance lets a new class be based on an existing class, automatically receiving (inheriting) its attributes and methods, then adding or changing what it needs. The existing class is the superclass (parent); the new one is a subclass (child).




Inheritance avoids duplicating shared code: define the common behaviour once in the parent, and each subclass only writes what makes it different.

What is polymorphism?

Polymorphism ("many forms") means the same method name can behave differently for different classes. A subclass can override a method it inherited with its own version — makeSound() might bark for a Dog object and squeak for a Puppy. Code can call makeSound() on any animal object without knowing its exact class, and the right version runs.

Why is OOP so useful?

These ideas combine into the big exam discussion: in a system with many similar entities (game characters, products, vehicles), OOP lets you model each as a class, share common code through inheritance, protect data with encapsulation, treat different objects uniformly through polymorphism, and reuse and test classes independently. That is why large systems and games favour OOP over procedural code — though for small, linear tasks, procedural remains simpler.

Common exam mistakes

  • Mixing up class and object. The class is the blueprint; the object is an instance created from it.

  • Vague encapsulation answers. Say private attributes + public get/set methods, and give the benefit (data cannot be set to invalid values; implementation can change safely).

  • Forgetting the constructor. Class-writing questions usually need public procedure new(...) to initialise the attributes.

  • Describing inheritance without direction. The subclass inherits from the superclass — and can add to or override what it receives.

  • Defining polymorphism as "many classes". It is the same method name behaving differently in different classes, usually via overriding.

Quick recap

  • Class = blueprint (attributes + methods); object = an instance of a class.

  • Encapsulation = private attributes accessed only via public get/set methods; protects data validity.

  • Inheritance = a subclass receives the superclass's attributes and methods, adding or overriding as needed (inherits, super.new).

  • Polymorphism = the same method name behaves differently in different classes (overriding).

  • OOP suits systems of many similar entities; know the OCR pseudocode class syntax cold.

Frequently asked questions

What is the difference between a class and an object? A class is a blueprint that defines the attributes and methods for a type of thing. An object is an instance of that class — one actual item created from the blueprint with its own attribute values.

What are attributes and methods? Attributes are the variables that store an object's data, such as a dog's name and age. Methods are the subroutines defined in the class that act on that data, such as getName() or setAge().

What is encapsulation and why is it used? Encapsulation keeps attributes private so they can only be accessed through public get and set methods. This lets the class control its data, for example rejecting invalid values, and allows the implementation to change without breaking other code.

What is inheritance in OOP? Inheritance lets a subclass be based on a superclass, automatically receiving its attributes and methods. The subclass can add new features or override inherited ones, so shared code is written once in the parent class.

What is polymorphism in OOP? Polymorphism means the same method name can behave differently for objects of different classes, usually because a subclass overrides an inherited method. Code can call the method without knowing the object's exact class.

How do I write a constructor in OCR pseudocode? Use a public procedure called new inside the class, taking parameters and assigning them to the attributes, for example: public procedure new(givenName) followed by name = givenName and endprocedure. Objects are created with myDog = new Dog("Rex").

 

 

 

Logo

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.


Follow us on:

Icon
Icon
Icon
Icon
Icon

Support@shuttlelearning.com

Logo

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.


Follow us on:

Icon
Icon
Icon
Icon
Icon

Support@shuttlelearning.com

Logo

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.


Follow us on:

Icon
Icon
Icon
Icon
Icon

Support@shuttlelearning.com