Further programming: paradigms, OOP, files and exceptions – A Level Computer Science (9618)

60 questions · page 1 of 4

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
1
9618/31/M/J/26 · Question 11May/June 2026Paper 318 marks
Loading question…
Question text

11
A declarative programming language is used to show which home cinema devices customers
already have and which devices they want.
01
device(projector).
02
device(large_tv).
03
device(medium_tv).
04
device(bluray_player).
05
device(amplifier).
06
device(media_player).
07
device(main_speakers).
08
device(centre_speaker).
09
device(surround_speakers).
10
customer(petrov).
11
customer(margaret).
12
customer(steffan).
13
customer(susan).
14
customer(allan).
15
customer(sammy).
16
owns(projector, petrov).
17
owns(media_player, petrov).
18
owns(projector, susan).
19
owns(projector, sammy).
20
owns(media_player, allan).
21
owns(bluray_player, steffan).
22
wants(main_speakers, margaret).
23
wants(surround_speakers, susan).
24
wants(medium_tv, steffan).
These facts (clauses) have the meanings:
fact
meaning
01
A projector is a device.
10
Petrov is a customer.
16
Petrov owns a projector.
22
Margaret wants main speakers.
(a) Betty is a customer who owns a large TV and wants a Blu‑ray player.
Write additional facts to represent this information.
25 …
26 …
27 …
[3]
© Cambridge University Press & Assessment 2026
,
,
(b) Using the variable Owner, the goal:
owns(media_player, Owner)
returns
Owner = petrov, allan
Write the result of using the goal:
owns(projector, Owner)
Owner = … [1]
(c) D may be available for A to buy if D is a device and A is a customer and A does not own
that device.
Write this as a rule:
may_buy_device(D, A)
IF …
…
…
… [4]
© Cambridge University Press & Assessment 2026
,
,
Permission to reproduce items where third‑party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (Cambridge University Press & Assessment) to trace copyright holders, but if any items requiring clearance
have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer‑related information to candidates, all copyright acknowledgements are reproduced online in our Copyright
Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cambridgeinternational.org after the live
examination series.
Cambridge International Education is the name of our awarding body and a part of Cambridge University Press & Assessment, which is a department of the
University of Cambridge.
© Cambridge University Press & Assessment 2026

2
9618/32/M/J/26 · Question 11May/June 2026Paper 329 marks
Loading question…
Question text

11
(a) Object-Oriented Programming (OOP) is used to design a class called Node.
A partial design of the Node class includes the STRING attribute Content and the INTEGER
attribute Pointer, together with their getters and setters.
The class also includes a constructor, with two parameters, to set the values of
these attributes.
Write pseudocode statements to declare the Node class, its attributes and the constructor.
…
…
…
…
…
…
…
…
…
… [5]
© Cambridge University Press & Assessment 2026
,
,
(b) Complete the table by filling in the missing OOP terms and descriptions.
OOP term
description
A method used to change values in private attributes in
…
a class.
…
An occurrence of a class during the execution of a program.
…
aggregation
…
…
…
inheritance
…
…
[4]
© Cambridge University Press & Assessment 2026
,
,
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (Cambridge University Press & Assessment) to trace copyright holders, but if any items requiring clearance
have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in our Copyright
Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cambridgeinternational.org after the live
examination series.
Cambridge International Education is the name of our awarding body and a part of Cambridge University Press & Assessment, which is a department of the
University of Cambridge.
© Cambridge University Press & Assessment 2026

3
9618/41/M/J/26 · Question 3May/June 2026Paper 4121 marks
Loading question…
Question text

3
A prototype for a game is designed using Object‑Oriented Programming (OOP).
The game will allow a character to move along a path (for example a road or sidewalk).
The prototype requires the classes setting up and the path creating ready for the character to
be implemented.
(a) Each space in the path can contain an object. The path and objects are created as classes.
The class TheObject stores the data about the objects. The attributes are public.
TheObject
ObjectType : String
stores the type of object, either "Money" or "Experience"
Amount : Integer
stores the amount of the object, for example 200
Constructor()
initialises the attributes to the parameter values
The class Path stores the data about the objects. The attributes are public.
Path
BoardArray[0:99] : TheObject
an array of 100 objects of type TheObject
NumberSpaces : Integer
stores the number of spaces in the path
Constructor()
initialises NumberSpaces to the parameter value.
Initialises all 100 array objects to an empty object of type
TheObject. An empty object has the values
ObjectType = "" and Amount = –1
GetNumberSpaces()
returns NumberSpaces
InitialiseData()
takes an array of objects of type TheObject as a
parameter and stores them in BoardArray
ReturnPath()
returns a string created using data from each object
in BoardArray
GetPathObject()
takes a number as a parameter and returns the object in
that index in BoardArray
Write program code to declare the class TheObject and its constructor.
(i)
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question3_J26.
Copy and paste the program code into 3(a)(i) in the evidence document.
[4]
© Cambridge University Press & Assessment 2026
Write program code to declare the class Path, its constructor and
(ii)
method GetNumberSpaces()
Use your programming language appropriate constructor.
Do not declare the other methods.
If you are writing in Python, include attribute declarations using comments.
Save your program.
Copy and paste the program code into 3(a)(ii) in the evidence document.
[4]
The method InitialiseData() takes an array of type TheObject as a parameter.
(iii)
The method stores each element from the parameter array into the array BoardArray
in the same order.
If there are more objects in the parameter array than in NumberSpaces, the method
does not store the data and returns FALSE. Otherwise, it returns TRUE
Write program code for InitialiseData()
Save your program.
Copy and paste the program code into 3(a)(iii) in the evidence document.
[3]
The method ReturnPath() creates and returns a string containing the type and
(iv)
amount of each object that is not a null object in BoardArray, in the format:
<ObjectType>-<Amount>
For example, an array with two not null objects produces the string:
Money-100 Experience-50
You can assume that there will always be an object that is not null in BoardArray
Write program code for ReturnPath()
Save your program.
Copy and paste the program code into 3(a)(iv) in the evidence document.
[2]
© Cambridge University Press & Assessment 2026
The method GetPathObject() takes an integer index as a parameter and returns the
(v)
object at the parameter index in BoardArray
Write program code for GetPathObject()
Save your program.
Copy and paste the program code into 3(a)(v) in the evidence document.
[1]
(b) (i)
Write program code for the main program to:
•
create a new array, ArrayOfObjects, of type TheObject with five spaces
•
store the following objects in each space in ArrayOfObjects in the order given:
money with amount 50
experience with amount 100
money with amount 200
money with amount 20
experience with amount 30
•
create a new object, Path1, of type Path with five spaces
•
call InitialiseData() for Path1 with ArrayOfObjects
•
call ReturnPath() for Path1 and output the return value.
Save your program.
Copy and paste the program code into 3(b)(i)

Advertisement
4
9618/42/M/J/26 · Question 2May/June 2026Paper 4230 marks
Loading question…
Question text

2
A program stores data about avatars in a program using Object‑Oriented Programming (OOP).
An avatar is a character that a user can control in a game.
The class Avatar stores the data about avatars.
Avatar
TheName : String
stores the name of the avatar
Glasses : Boolean
stores TRUE if the avatar wears glasses
stores FALSE if the avatar does not wear glasses
Hair : String
stores the colour of the avatar's hair
Age : Integer
stores the age of the avatar
Constructor()
initialises all attributes to its parameter values
GetName()
returns the name of the avatar
GetAge()
returns the age of the avatar
MeetCriteria()
takes the glasses choice and hair choice as parameters
and returns whether the avatar matches the choices
Write program code to declare the class Avatar and its constructor. All attributes must
(a) (i)
be private.
Do not declare the other methods.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question2_J26.
Copy and paste the program code into 2(a)(i) in the evidence document.
[4]
The get methods GetName() and GetAge() each return the relevant attribute.
(ii)
Write program code for GetName() and GetAge()
Save your program.
Copy and paste the program code into 2(a)(ii) in the evidence document.
[3]
© Cambridge University Press & Assessment 2026
The method MeetCritera() takes two parameters:
(iii)
•
a Boolean value to identify whether the avatar wears glasses
•
a string value to identify the hair colour.
The method checks whether this avatar’s attributes match both of the parameters.
Boolean TRUE is returned when both of the attributes match the parameters, otherwise
Boolean FALSE is returned.
Write program code for MeetCriteria()
Save your program.
Copy and paste the program code into 2(a)(iii) in the evidence document.
[2]
The text file AvatarFile.txt stores data for 30 avatars. Each avatar is on a new line
(b) (i)
in the file. The data is stored in the order: name, glasses, hair colour, age. Each value is
separated by a space.
For example, the first line in the file is:
Kit True blonde 21
The name of the avatar is Kit, the avatar wears glasses, the avatar has blonde hair, the
avatar is 21 years old.
The procedure LoadAvatars() reads the data from the text file into the program. The
function creates a new object for each avatar in the file and stores the avatar objects in
a global array with the identifier AvailableAvatars
The procedure uses exception handling when opening and reading from the file.
Write program code for LoadAvatars()
Save your program.
Copy and paste the program code into 2(b)(i) in the evidence document.
[7]
Write program code for the main program to call LoadAvatars()
(ii)
Save your program.
Copy and paste the program code into 2(b)(ii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026
The procedure EnterChoices() prompts the user to enter whether they want an
(c) (i)
avatar that wears glasses and the hair colour they want.
The procedure takes these two values as input until they are valid:
•
wearing glasses can only be yes or no
•
the hair colour can be black, blonde, brown, pink, red or green.
The procedure calls the method MeetCriteria() for each avatar in
AvailableAvatars and stores the avatars that match the criteria in a global array.
Write program code for EnterChoices()
Save your program.
Copy and paste the program code into 2(c)(i) in the evidence document.
[6]
(ii)
Write program code to extend the main program to:
•
call EnterChoices()
•
output the quantity of avatars that match the criteria
•
output the name and age of each avatar that matches the criteria.
All outputs must include an appropriate message.
Save your program.
Copy and paste the program code into 2(c)(ii) in the evidence document.
[5]
© Cambridge University Press & Assessment 2026
(d) (i)
Test your program with the following data as input:

5
9618/43/M/J/26 · Question 2May/June 2026Paper 4329 marks
Loading question…
Question text

2
A prototype for a game is being developed using Object‑Oriented Programming (OOP).
The game has a set of characters that have data stored about their characteristics, for example
if the character can fly or not fly. A user has to select their requirements, for example a character
that can fly, and the program will output the characters that meet the user’s requirements.
The class Character stores the data about the characters. The attributes are public.
Character
CharacterName : String
stores the character’s name
Colour : String
stores the colour of the character, for
example "Green"
SuperStrength : String
stores whether the character has super strength
("Yes") or not ("No")
Fly : String
stores whether the character can fly ("Yes") or
not ("No")
Invisible : String
stores whether the character can become
invisible ("Yes") or not ("No")
Constructor()
initialises the attributes to its parameter values
GetCharacterName()
returns CharacterName
GetColour()
returns Colour
GetSuperStrength()
returns SuperStrength
GetFly()
returns Fly
GetInvisible()
returns Invisible
Write program code to declare the class Character and its constructor.
(a) (i)
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question2_J26.
Copy and paste the program code into 2(a)(i) in the evidence document.
[4]
© Cambridge University Press & Assessment 2026
The get methods GetCharacterName(), GetColour(), GetSuperStrength(),
(ii)
GetFly() and GetInvisible() each return the appropriate attribute.
Write program code for GetCharacterName(), GetColour(),
GetSuperStrength(), GetFly() and GetInvisible()
Save your program.
Copy and paste the program code into 2(a)(ii) in the evidence document.
[3]
(b) The text file Characters.txt stores data about 15 characters. Each character is on a new
line in the file. The data is stored in the order: Character name, colour, super strength, fly,
invisible. Each value is separated by a comma.
For example, the first line in the file is:
Jet,Black,Yes,No,No
The name of the character is Jet. The colour of the character is Black. The character has
super strength. The character cannot fly. The character cannot become invisible.
The function ReadData():
•
opens the file Characters.txt and reads in the data
•
creates a new Character object for each character in the file
•
stores each Character object in a local array
•
returns the populated array.
The function uses exception handling when opening and reading from the file.
Write program code for ReadData()
Save your program.
Copy and paste the program code into 2(b) in the evidence document.
[7]
© Cambridge University Press & Assessment 2026
(c) The procedure OutputCharacters() takes an array of Character objects as a
parameter. The procedure outputs the data for each character on a new line, in the format:
Name: <Character name> Colour: <Colour> Super strength: <Super
strength> Fly: <Fly> Invisible: <Invisible>
For example:
Name: Jet Colour: Black Super strength: Yes Fly: No Invisible: No
Write program code for OutputCharacters()
Save your program.
Copy and paste the program code into 2(c) in the evidence document.
[3]
The main program calls ReadData() and then OutputCharacters() with the
(d) (i)
returned array.
Write program code for the main program.
Save your program.
Copy and paste the program code into 2(d)(i) in the evidence document.
[2]
(ii)
Test your program
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot into 2(d)(ii) in the evidence document.
[1]
© Cambridge University Press & Assessment 2026
(e) The main program needs to give the user two choices to limit the characters that they can
choose from. For example, they could choose to only see characters that are green and that
can fly.
(i)
The main program needs extending to:
•
prompt the user to enter two criteria and take both as input.

6
9618/31/O/N/25 · Question 10Oct/Nov 2025Paper 313 marks
Loading question…
Question text

10 Explain what is meant by exception handling.
Include an example of a possible cause of an exception in your answer.
Explanation …
…
…
…
Example …
[3]
ĬÙú¾Ġ´íÈõÏĪÅĊàû·þ×

7
9618/32/O/N/25 · Question 10Oct/Nov 2025Paper 324 marks
Loading question…
Question text

10 An exception is an error that may cause a program to halt unexpectedly.
(a) Describe how program termination due to an exception can be avoided.
…
…
…
…
… [2]
(b) Identify two possible causes of exceptions.
1 …
…
2 …
…
[2]
ĬÓĊ®Ġ´íÈõÏĪÅĊßùµĀ×

8
9618/33/O/N/25 · Question 12Oct/Nov 2025Paper 335 marks
Loading question…
Question text

12 An exception can occur when running a program.
(a) Explain what is meant by an exception.
…
…
…
…
…
… [3]
(b) Identify one example of an exception and give one reason why the exception may cause a
problem.
Example …
…
Reason …
…
[2]
ĬÛú¾Ġ´íÈõÏĪÅĊàû¶Ā×

Advertisement
9
9618/41/O/N/25 · Question 2Oct/Nov 2025Paper 4130 marks
Loading question…
Question text

2
A program stores data about trains and train stations using Object-Oriented Programming (OOP).
The class Train stores the data about the trains:
Train
TrainIDNumber : String
stores the train ID number
Route : Integer
stores the route number the train is travelling
initialises TrainIDNumber and Route to the parameter
Constructor()
values
GetTrainIDNumber()
returns the train ID number
GetRoute()
returns the route number the train is travelling
Write program code to declare the class Train and its constructor.
(a) (i)
Do not declare the other methods.
All attributes should be private.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question2_N25.
Copy and paste the program code into part 2(a)(i) in the evidence document.
[4]
The methods GetTrainIDNumber() and GetRoute() return the appropriate attribute.
(ii)
Write program code for GetTrainIDNumber() and GetRoute()
Save your program.
Copy and paste the program code into part 2(a)(ii) in the evidence document.
[3]
(b) The program is tested with four trains:
train ID number
route
12ADV
134
33ART
20
9FKF
3
21VBC
24
Write program code to declare an instance of Train for each of the four trains.
Save your program.
Copy and paste the program code into part 2(b) in the evidence document.
[2]
(c) The class Station stores the data about the stations:
Station
StationID : String
stores the station ID
NumberPlatforms : Integer
stores the number of platforms at the station
Trains[0:9] : Train
stores the trains currently at the station platforms
NumberTrains : Integer
stores the number of trains currently at the station
platforms
initialises StationID and NumberPlatforms
Constructor()
to the parameter values, initialises Trains to an
empty array and NumberTrains to 0
GetTrains()
returns a string containing data about the trains
currently at the station platforms
takes a Train parameter and stores it if there is a
AddTrain()
platform available; each platform can only have one
train
Write program code to declare the class Station and its constructor.
(i)
Do not declare the other methods.
All attributes should be private.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program.
Copy and paste the program code into part 2(c)(i) in the evidence document.
[3]
The method AddTrain() takes a Train parameter. The method compares the
(ii)
attributes NumberTrains and NumberPlatforms to identify if there is a platform
available (a platform currently with no train).
The method returns FALSE if there are no platforms available.
If there is a platform available, the method:
•
stores the Train parameter in the array Trains
•
updates the appropriate attribute(s)
•
returns TRUE
Write program code for AddTrain()
Save your program.
Copy and paste the program code into part 2(c)(ii) in the evidence document.
[4]
The method GetTrains() returns the string "There are no trains" if there are no
(iii)
trains at the station platforms.
If there are trains at the station platforms, the method returns a string in the format:
The trains at station <StationID> are:
<TrainIDNumber> on route number <Route>
The line <TrainIDNumber> on route number <Route> is repeated for each train
at the station platforms.
For example: If the station with the station ID "NT1" has two trains with the train ID
numbers "48RTG", "6UFH", the method will produce this output:
The trains at station NT1 are:
48RTG on route number 43
6UFH on route number 12
Write program code for GetTrains()
Save your program.
Copy and paste the program code into part 2(c)(iii) in the evidence document.
[6]
(d) The program is tested with two stations:
number of
station ID
platforms
STH
2
NTH
1
Write program code to amend the main program to declare an instance of Station for
(i)
each of the two

10
9618/41/O/N/25 · Question 3Oct/Nov 2025Paper 4125 marks
Loading question…
Question text

A program stores records in the 2D array HashTable. Each record is stored at a specific index of
3
the array that is calculated using a hashing algorithm with the record’s key field.
The array has 100 × 10 elements. The hashing algorithm uses the key to generate an index
between 0 and 99 (inclusive). If two key fields generate the same index, there is a collision. Any
records that have a collision are stored in the next space in the same index.
For example: In this table two record keys generated the same hash value of 1. Four record keys
generated the same hash value of 3.
Index
0
1
2
3
4
5
…
9
0
record
1
record
record
2
3
record
record
record
record
4
…
99
The program uses Object-Oriented Programming (OOP).
(a) The class Record stores data about the records:
Record
Key : Integer
stores the integer key field for the data
Data : String
stores the string data
initialises Key and Data to its parameter values
Constructor()
The attributes Key and Data are public.
Write program code to declare the class Record and its constructor.
Use your programming language appropriate constructor.
Save your program as Question3_N25.
Copy and paste the program code into part 3(a) in the evidence document.
[2]
(b) The procedure InitialiseHashTable() initialises each element in the array to an empty
or null record.
Write program code to declare the global 2D array HashTable and the procedure
InitialiseHashTable()
Save your program.
Copy and paste the program code into part 3(b) in the evidence document.
[2]
(c) The function Hash():
•
takes an integer key field as a parameter
•
calculates and returns the hash value of the key field.
The hash value is the result from the formula: key MOD 100
Write program code for Hash()
Save your program.
Copy and paste the program code into part 3(c) in the evidence document.
[2]
(d) The procedure InsertData():
•
takes an object of type Record as a parameter
•
calculates the hash value for the parameter using the appropriate function
•
stores the parameter in the correct position in HashTable
You can assume there will be no more than 10 objects that generate the same hash value.
Write program code for InsertData()
Save your program.
Copy and paste the program code into part 3(d) in the evidence document.
[4]
(e) The file "HashTableData.txt" stores 200 key values and string data items in the format:
key,string
For example, the first row in the text file is:
528,permission
The key is 528 and the string data is "permission"
The procedure ReadData():
•
opens the text file and reads each line
•
splits each line into the key and data
•
calls InsertData() with an object containing each key and matching data.
Write program code for ReadData()
Save your program.
Copy and paste the program code into part 3(e) in the evidence document.
[5]
The function GetRecord():
(f)
•
takes an integer key field as a parameter
•
calculates the hash value for the key field using the appropriate function
•
searches the hash table for the record with the matching key field
•
returns the data for the record if the record is found
•
returns "Not found" if the record is not found.
Write program code for GetRecord()
Save your program.
Copy and paste the program code into part 3(f) in the evidence document.
[5]
(g) The main program:
•
calls InitialiseHashTable() and ReadData()
•
takes five integer key fields as input from the user
•
calls GetRecord() with each input and outputs the return value.
(i)
Write program code for the main program.
Save your program.
Copy and paste the program code into part 3(g)(i) in the evidence document.
[3]
(ii)
Test your program with the following five inputs in the order given:
528
1128
1828
1062
39
Take a screenshot of the output(s).
Save your program.
Copy and paste the screenshot(s) into part 3(g)(ii) in the evidence document.
[2]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and

11
9618/42/O/N/25 · Question 1Oct/Nov 2025Paper 4228 marks
Loading question…
Question text

1
A program stores data about birds using Object-Oriented Programming (OOP).
The class Bird stores the data about the birds:
Bird
DistancePerHour : Real
stores the number of kilometres per hour (km/h) the bird
can fly (between 0.0 and 100.0 inclusive)
Species : String
stores the species of the bird, for example Pigeon
XPosition : Real
stores the current horizontal position of the bird
YPosition : Real
stores the current vertical position of the bird
Constructor()
initialises Species and DistancePerHour to the
parameter values; initialises XPosition and YPosition
to 500.0
GetPosition()
returns a string message that contains the horizontal and
vertical position of the bird
GetSpecies()
returns the species of the bird
Move()
takes a direction and number of minutes flying (between
0 and 500 inclusive) as parameters and updates the
appropriate horizontal or vertical position
Write program code to declare the class Bird and its constructor.
(a) (i)
Do not declare the other methods.
All attributes should be private.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question1_N25.
Copy and paste the program code into part 1(a)(i) in the evidence document.
[4]
The method GetSpecies() returns the species of the bird.
(ii)
Write program code for GetSpecies()
Save your program.
Copy and paste the program code into part 1(a)(ii) in the evidence document.
[2]
The method GetPosition() returns a string of the bird’s data in the format:
(iii)
"X = " & <XPosition> & " Y = " & <YPosition>
An example string for a bird is:
X = 500.0 Y = 250.0
Write program code for GetPosition()
Save your program.
Copy and paste the program code into part 1(a)(iii) in the evidence document.
[3]
(iv)
If the bird is travelling north, the vertical position increases. If the bird is travelling south,
the vertical position decreases.
If the bird is travelling east, the horizontal position increases. If the bird is travelling west,
the horizontal position decreases.
The method Move():
•
takes the direction of travel as a parameter in the form ‘N’ for north, ‘S’ for south,
‘E’ for east or ‘W’ for west
•
takes the number of minutes that the bird has been flying (to the nearest minute) as
a parameter
•
calculates the distance travelled by the bird using the formula:
distance travelled = (distance per hour / 60) * minutes flying
•
updates the vertical or horizontal position using the distance calculated.
You do not need to validate the parameters.
Write program code for Move()
Save your program.
Copy and paste the program code into part 1(a)(iv) in the evidence document.
[5]
(b) The main program creates two instances of Bird
The first bird is the species ‘Cockatiel’ and flies 71.0 km/h.
The second bird is the species ‘Macaw’ and flies 56.0 km/h.
Write program code to declare and initialise the two birds.
Save your program.
Copy and paste the program code into part 1(b) in the evidence document.
[3]
(c) (i)
The main program needs to:
•
output a message that includes the species and current X position and Y position for
each bird
•
prompt the user to select one of the birds to move and take this as an input
•
prompt the user to enter the direction the bird has been travelling and take this as
an input
•
prompt the user to enter the time to the nearest minute that the bird has been
travelling and take this as an input
•
call the appropriate method to update the chosen bird’s position
•
output an update on the bird’s new position.
Each input needs to repeat until valid data is entered. All outputs must be meaningful.
Write program code to amend the main program.
Save your program.
Copy and paste the program code into part 1(c)(i) in the evidence document.
[8]
(ii)
Test your program four times to meet these criteria:
Test 1: The Cockatiel travels north for 60 minutes.
Test 2: The Macaw travels south for 30 minutes.
Test 3:

12
9618/43/O/N/25 · Question 1Oct/Nov 2025Paper 4331 marks
Loading question…
Question text

1
A program stores data for a board game using Object-Oriented Programming (OOP). The game
has objects that are placed on the board. Each object has a string code (for example "A") and an
integer value (for example, 2).
The class BoardObject stores the data about the objects that can be placed on the board:
BoardObject
Code : String
stores the board object’s code
Value : Integer
stores the integer value of the board object
Constructor()
initialises the attributes to the parameter values
GetCode()
returns Code
GetValue()
returns Value
Write program code to declare the class BoardObject and its constructor.
(a) (i)
Do not declare the other methods.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question1_N25.
Copy and paste the program code into part 1(a)(i) in the evidence document.
[5]
The methods GetCode() and GetValue() return the appropriate attribute.
(ii)
Write program code for GetCode() and GetValue()
Save your program.
Copy and paste the program code into part 1(a)(ii) in the evidence document.
[3]
(iii)
The table shows the code and value of five board objects. The table has the variable
identifier where each of the objects are stored.
Variable
Code
Value
identifier
Object1
"A"
2
Object2
"B"
3
Object3
"C"
5
Object4
"D"
2
Object5
"E"
7
Write program code for the main program to instantiate each of the five board objects
and store them in the variables with the identifiers given.
Save your program.
Copy and paste the program code into part 1(a)(iii) in the evidence document.
[3]
(b) The board objects are placed on a board that is represented by a 0-indexed 2D array:
•
the board is a 10 x 10 grid
•
each position on the board is identified by a row and column number
•
rows are numbered 0 to 9
•
columns are numbered 0 to 9
•
board objects can be placed at a row and column position
•
each board position is initialised with an empty BoardObject, an empty BoardObject
has Code = "-" and Value = 0
For example, the element highlighted in the given board is in row 1 and column 3.
Row
Column
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
The class Board stores the data about the board and where the board objects are placed.
Board
TheBoard : ARRAY[0:9, 0:9] of BoardObject
stores the board contents as a 2D array of
10 x 10 elements of type BoardObject
Constructor()
initialises each of TheBoard elements to
an empty BoardObject with Code = "-"
and Value = 0
GetObject()
takes a row and column number as
parameters and returns the BoardObject
at the row, column position
SetObject()
takes a BoardObject, row number and
column number as parameters. Stores the
BoardObject in TheBoard at the given
row, column position
DisplayBoard()
outputs the code of each BoardObject
stored in TheBoard, one row at a time
Write program code to declare the class Board and its constructor.
(i)
Do not declare the other methods.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.
Save your program.
Copy and paste the program code into part 1(b)(i) in the evidence document.
[4]
The method GetObject() takes a row number and column number as parameters.
(ii)
The method returns the BoardObject stored at the parameter position.
Write program code for GetObject()
Save your program.
Copy and paste the program code into part 1(b)(ii) in the evidence document.
[2]
The method SetObject() takes three parameters: a BoardObject, row number and
(iii)
column number.
The method stores the BoardObject parameter in the row, column position in
TheBoard
Write program code for SetObject()
Save your program.
Copy and paste the program code into part 1(b)(iii) in the evidence document.
[2]
The method DisplayBoard() outputs the Code of each BoardObject stored in
(iv)
TheBoard using GetCode()
Each row in TheBoard is output on one li

13
9618/31/M/J/25 · Question 11May/June 2025Paper 318 marks
Loading question…
Question text

11
(a) A medical centre uses objects of the class Appointment to record treatments given and
medication prescribed during each doctor’s appointment. Some of the attributes required in
the class are listed in the table.
Attribute
Data type
Description
DateSeen
DATE
date of treatment
Treatments
STRING
treatments given
Medications
STRING
medications prescribed
Patients are identified by a unique 8-digit number, beginning with the patient’s year of birth,
for example, 20108989.
Doctors are identified by their name, for example, A N Other.
Complete the class diagram for Appointment, to include:
•
attribute and data type for the identification of the patient
•
attribute and data type for the identification of the doctor
•
methods to assign date seen, treatments given and medications prescribed
•
method to return the date seen and the attributes for the patient and the doctor.
Appointment
DateSeen
: DATE
… : …
… : …
Treatments
: STRING
Medications
: STRING
…
SetPatientID(PatientNumber : INTEGER)
SetDoctor(DoctorID : STRING)
…
…
…
…
…
GetTreatments()
GetMedications()
[5]
ĬÑĊ®Ġ´íÈõÏĪÅĊÞû¸Ā×
,
,
(b) (i)
Identify the object-oriented programming (OOP) feature whose function includes
restricting external access to the data.
… [1]
(ii)
Describe what is meant by the OOP feature inheritance.
…
…
…
… [2]

Advertisement
14
9618/31/M/J/25 · Question 12May/June 2025Paper 315 marks
Loading question…
Question text

12 The pseudocode algorithm checks whether a location in a stock file StockList.dat is empty
or not. The location is given by the user. If the location is empty, a suitable message is displayed,
otherwise the item stored at that location is displayed.
Complete this file-handling pseudocode algorithm.
DECLARE Location : INTEGER
DECLARE Item : STRING
DECLARE Continue : BOOLEAN
DECLARE Answer : CHAR
TRUE
Continue
OPENFILE …
WHILE Continue
OUTPUT "Enter a location between 1 and 500: "
INPUT Location
…
GETRECORD …
IF Item = "" THEN
OUTPUT "This record is missing."
ELSE
OUTPUT "The item in stock is ", …
ENDIF
OUTPUT "Another location (Y or N)?"
INPUT Answer
IF Answer <> 'Y' THEN
FALSE
Continue
ENDIF
ENDWHILE
…
OUTPUT "End of program"
[5]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞù¸Ā×
,
,
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
ĬÍĊ®Ġ´íÈõÏĪÅĊßúµĄ×

15
9618/32/M/J/25 · Question 12May/June 2025Paper 328 marks
Loading question…
Question text

12 (a) A medical clinic uses objects of the class Patient to assign a priority and a doctor to a
patient. Some of the attributes required in the class are listed in the table.
Attribute
Data type
Description
PatientID
STRING
Unique identifier of the patient
Name
STRING
Patient’s full name, surname first
DoctorID
STRING
ID of doctor administering treatment
Treatment is prioritised with a numeric scale of 1 to 5.
Complete the class diagram for Patient, to include:
•
attribute and data type for the date of birth
•
attribute and data type for the priority
•
methods to assign the patient ID, priority and doctor ID
•
methods to return the patient ID, patient date of birth and the priority.
Patient
PatientID
: STRING
Name
: STRING
… : …
… : …
DoctorID
: STRING
…
SetName(FullName : STRING)
SetDateOfBirth(DOB : DATE)
…
…
…
GetName()
…
…
GetDoctorID()
[5]
ĬÑĊ®Ġ´íÈõÏĪÅĊàù¸Ā×
,
,
(b) (i)
Identify the object-oriented programming (OOP) term described as ‘an occurrence of an
object’.
… [1]
(ii)
Describe what is meant by the OOP term polymorphism.
…
…
…
… [2]

Advertisement