Revision Notes
OxfordAQA A-Level Computer Science: Object-oriented and additional programming (9645) – Revision Notes
Condensed notes for OxfordAQA A-Level Computer Science (9645) on classes, access modifiers, inheritance, overriding, association, files and recursion.
- Subject
- Computer Science
- Level
- A LEVEL
- Topic
- Object-oriented and additional programming
- Author
- Marlbridge Academic Team
- Updated
Aligned to OxfordAQA A Level Computer Science (9645), 2024-onwards. Official specification .
Syllabus page (what it covers and how it is assessed): OxfordAQA A Level Computer Science.
Syllabus points this page covers
9645 (A Level)
- 9 Object-oriented and additional programming (whole topic)
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (9645).
These notes condense section 3.9 Object-oriented and additional programming (3.9.1 to 3.9.4) of the OxfordAQA International AS and A-level Computer Science (9645) specification, Version 1.1, for International AS exams May/June 2025 onwards and International A-level exams May/June 2026 onwards. Nothing here is in the International AS; the content is assessed in Unit 3: Advanced Programming, which you sit on screen using C#, Python or VB.Net. If a point below is unfamiliar, go back to the study guide, which explains each idea with longer examples.
When these feel secure, move on to the practice set. Other topics in this course sit on the hub, /boards/oxfordaqa/a-level/computer-science/; tick outcomes off on the checklist, /checklists/oxfordaqa/a-level/computer-science/; and the free diagnostics show which topics need work. Code is in Python; the specification sets no pseudo-code style for this section.
3.9.1 Key terms (International A-level only)
| Term | Definition to learn |
|---|---|
| Class | Defines the attributes and methods that capture the common characteristics and behaviours of a type of object |
| Property / attribute | A data field held by each object |
| Method | A subroutine defined in a class |
| Object | One instance of a class, with its own attribute values |
| Instantiation | Creating an object from a class |
| Constructor | Called when an object is instantiated; initialises it to a given state. Explicit if you write it, implicit if the language supplies it |
| Encapsulation | Hiding how a class works and how it represents data from other classes |
| Inheritance | One class is a more specialised version of an existing class |
| Overriding | A base-class method is redefined in a subclass so subclass instances behave differently |
| Association | One object can make use of another; much weaker than inheritance |
Why use the paradigm? It models problems as interacting objects, protects data behind methods, lets subclasses reuse tested code, and lets each class be built and tested separately.
Small reminder
class Telescope:
def __init__(self, aperture_mm):
self.aperture_mm = aperture_mm
self.zoom = 1
scope = Telescope(90)
Telescope is the class. __init__ is the constructor. scope = Telescope(90) is instantiation. The new object’s state is aperture_mm 90 and zoom 1. A second Telescope(120) would be a separate object.
3.9.2 Access modifiers and encapsulation
| Modifier | Symbol | Accessible from | Python convention | C# / VB.Net |
|---|---|---|---|---|
| public | + | anywhere | name |
public / Public |
| private | - | the class only | __name (name mangled) |
private / Private |
| protected | # | the class and its subclasses | _name (convention only) |
protected / Protected |
Method in steps: designing an encapsulated class
- Make every attribute private unless there is a reason not to.
- Add a getter for each value other classes must read.
- Add a setter only where outside change is allowed, and validate inside it.
- Have the setter report failure (return False, or raise an exception).
- Make an attribute protected only when a subclass needs it.
A reminder in code, with a lap counter that may only go up:
class LapCounter:
def __init__(self):
self.__laps = 0
def get_laps(self):
return self.__laps
def add_lap(self):
self.__laps = self.__laps + 1
There is no setter at all, so no outside class can lower the count. Encapsulation is about choosing what to expose, not only adding getters and setters for everything.
3.9.3 Relationships between classes
Inheritance in steps
- Put shared attributes and methods in the base class (parent class).
- Declare the subclass (derived class):
class Sub(Base):in Python,class Sub : Basein C#,Inherits Basein VB.Net. - In the subclass constructor, call the base constructor first (
super().__init__(...)in Python). - Add only what is new.
- Override any method that must behave differently.
Overriding keywords
| Language | Base-class method | Subclass method |
|---|---|---|
| C# | virtual |
override |
| VB.Net | Overridable |
Overrides |
| Python | no keyword | same name |
An inherited method that calls an overridden one runs the subclass version when the object is a subclass instance.
Must-know distinctions
- Class vs object. A class is written once; many objects are made from it.
- Inheritance vs association. “Is a more specialised kind of” means inheritance. “Uses” or “has a link to” means association. A Ward is associated with its Patients; a Ward is not a kind of Patient.
- Private vs protected. Both hide a member from unrelated classes. Only protected lets subclasses in.
- Overriding vs adding. Overriding redefines an inherited method with the same name. Adding a new method is not overriding.
- Aggregation vs composition. Not required: the specification says you will not need to distinguish them.
Class diagram key
- Inheritance: a line with an unfilled triangle head; by convention the triangle points at the base class.
- Association: a plain line between the two classes.
- Each box: class name, then attributes, then methods, each marked +, - or #.
- A subclass box repeats only new members and overridden methods.
3.9.4.1 Text files
Method in steps: reading
- Open in
"r"mode. - Loop over lines.
strip()the newline; convert withint()orfloat()if needed;split(",")for several fields.- Close (automatic with
with).
Method in steps: writing
- Open in
"w"(new or wipe) or"a"(add to end). - Convert numbers with
str(). - Write each line with
"\n"at the end. - Close, so the data is saved.
with open("log.txt", "a") as f:
f.write("door opened\n")
This adds one line to the end of log.txt and creates the file if it does not exist.
3.9.4.2 Recursion
- A recursive subroutine calls itself.
- Base case: the subroutine does not call itself. It stops the recursion.
- Recursive case: it calls itself on a smaller problem.
- There may be more than one of each.
- With no reachable base case it recurses indefinitely; in practice the program crashes with a stack overflow (a
RecursionErrorin Python).
Method in steps: tracing
- Write the first call.
- Below it, write each new call with its argument, indenting one level.
- Stop at a base case and write its return value.
- Work back up, replacing each call with its value.
Worked reminder.
def halvings(n):
if n <= 1:
return 0
return 1 + halvings(n // 2)
halvings(40): 40 → 20 → 10 → 5 → 2 → 1. The base case returns 0; five recursive calls each add 1. Result: 5.
Quick self-test
- What does a constructor do?
- Name the three access modifiers and their class diagram symbols.
- Which Python naming style is enforced by the interpreter, and how?
- State one reason for using getters and setters rather than public attributes.
- Which C# keyword must a base-class method carry before it can be overridden?
- An
Orchestraobject stores references to severalViolinistobjects. Which relationship is this? - A file is opened with
"w"and already holds 30 lines. One line is written. How many lines does it now hold? - What does this return for
tri(6)?
def tri(n):
if n == 0:
return 0
return n + tri(n - 1)
- What does
echo("lamp")return?
def echo(s):
if len(s) <= 1:
return s
return s[-1] + echo(s[:-1])
- What does
step3(14)return?
def step3(n):
if n < 3:
return n
return step3(n - 3) + 1
Answers
- It is called when an object is instantiated and initialises the object to a given state.
- Public (+), private (-), protected (#).
- A double leading underscore (private): the name is mangled to
_ClassName__name. A single underscore is only a convention. - The setter can validate a new value before storing it, so the object cannot reach an invalid state.
virtual(the subclass method usesoverride).- Association.
- One line.
"w"wipes the existing content first. - 21 (6 + 5 + 4 + 3 + 2 + 1 + 0).
- “pmal”. Each call takes the last character and puts it in front.
- 6. 14 → 11 → 8 → 5 → 2; the base case returns 2 and four recursive calls add 1 each.
Where marks are usually lost
- Defining a constructor as “creates the object” without saying it sets the starting state.
- Writing “encapsulation means private attributes” with no mention of hiding how the class works.
- Making a base-class attribute private and then reading it in a subclass method.
- Forgetting to call the base constructor, so inherited attributes are never set.
- Overriding with a different name, which adds a method instead of replacing one.
- In C# or VB.Net, forgetting
virtual/Overridableon the base method. - Calling a “uses” link inheritance, or drawing the inheritance triangle at the subclass end.
- Not stripping newlines before converting a line to a number.
- Choosing
"w"instead of"a"and losing existing file data. - A recursive case that does not move towards the base case, or a trace that stops before working back up.
Official syllabus
OxfordAQA International AS and A-level Computer Science (9645) specification, Version 1.1, for International AS exams May/June 2025 onwards and International A-level exams May/June 2026 onwards, published by OxfordAQA. Section 3.9 Object-oriented and additional programming.
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.
Related resources
-
Study guides
OxfordAQA A-Level Computer Science: Object-oriented and additional programming (9645)
Study guide to OxfordAQA A-Level Computer Science section 3.9: classes, constructors, encapsulation, inheritance, association, text files and recursion.
Computer Science · OxfordAQA · A Level
Read guide -
Practice questions
OxfordAQA A-Level Computer Science: Object-oriented and additional programming (9645) – Practice Questions
Original practice questions with worked answers for OxfordAQA A-Level Computer Science (9645): classes, inheritance, encapsulation, files, recursion.
Computer Science · OxfordAQA · A Level
Try questions -
Study guides
OxfordAQA A-Level Computer Science: Program design (9645)
Study guide to OxfordAQA A-Level Computer Science program design: structured code, charts, abstraction, tracing, testing and evaluation.
Computer Science · OxfordAQA · AS Level
Read guide
Related articles
-
teaching
A Level tuition in Dubai: Cambridge or Pearson Edexcel International A Level?
Schools in Dubai and Abu Dhabi teach either Cambridge International AS & A Level or Pearson Edexcel International A Level. How the two are structured, why it matters for tuition, and how online classes from Lahore work.
9 October 2026
-
curriculum guides
Choosing subjects at IGCSE and A Level
How subject choices at 14 and 16 affect university options later, and how to keep pathways open without overloading a timetable.
28 July 2026
Studying this with a teacher
Working through Computer Science A LEVEL?
This page is free and stays free. If you would rather be taught it, Marlbridge runs Computer Science classes one-to-one and in small groups of up to 15, online in your own time zone. The first trial class is free. WhatsApp replies within an hour (8am–11pm Pakistan time, every day); email the same day.
OxfordAQA Computer Science teachers at Marlbridge