Further programming: paradigms, OOP, files and exceptions – A Level Computer Science (9618)
20 questions · page 1 of 2 · Clear filters
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
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
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]
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
ĬÍĊ®Ġ´íÈõÏĪÅĊßúµĄ×
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]
Question text
13 The pseudocode algorithm below uses random file access to copy 50 records from a live file
CurrentResults.dat to a stored file StoredResults.dat one record at a time. It uses the
user-defined type StudentResult.
TYPE StudentResult
DECLARE LastName : STRING
DECLARE FirstName : STRING
DECLARE ExamGrade : STRING
ENDTYPE
If any grades are missing in CurrentResults.dat, the text "Missing grade" is added to the
ExamGrade field in StoredResults.dat
Complete this file handling pseudocode algorithm.
DECLARE Grade : StudentResult
DECLARE Position : INTEGER
…
OPENFILE "StoredResults.dat" FOR RANDOM
…
SEEK "CurrentResults.dat", Position
GETRECORD "CurrentResults.dat", Grade
IF Grade.ExamGrade = "" THEN
…
ENDIF
…
…
NEXT Position
CLOSEFILE "CurrentResults.dat"
CLOSEFILE "StoredResults.dat"
[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
ĬÍĊ®Ġ´íÈõÏĪÅĊÝüµĄ×
Question text
5
Complete the table by filling in the missing object-oriented programming (OOP) terms and
descriptions.
OOP term
Description
A method that accesses the value of a property.
…
A method that changes the value of a property.
…
…
Object
…
…
…
Method
…
…
[4]
Question text
11
The pseudocode algorithm below allows a user to input a new stock item. The random file is
searched for the next empty location in the file and the new item is inserted there.
A suitable message is displayed if the file is full.
Complete this pseudocode.
DECLARE Location : INTEGER
DECLARE NewStock : STRING
DECLARE CurrentStock : STRING
DECLARE Stored : BOOLEAN
DECLARE Max : INTEGER
←
100000
Max
←
FALSE
Stored
←
1
Location
…
OUTPUT "Enter the new item you wish to store: "
INPUT NewStock
WHILE NOT Stored AND Location <= Max
…
GETRECORD "StockList.dat", …
IF CurrentStock = "" THEN
… "StockList.dat", NewStock
←
TRUE
Stored
ELSE
←
Location + 1
Location
ENDIF
ENDWHILE
… THEN
OUTPUT "The new item has not been stored as the file was full."
ENDIF
CLOSEFILE "StockList.dat"
[5]
ĬÓĊ®Ġ´íÈõÏĪÅĊßú¸Ā×
Question text
8
A declarative programming language is used to represent the features that are available and the
features that are unavailable on different body styles of a car.
01
feature(sunroof).
02
feature(automatic_tailgate).
03
feature(heated_seats).
04
feature(extra_seats).
05
feature(reversing_camera).
06
feature(dashboard_camera).
07
feature(air_conditioning).
08
feature(heated_windscreen).
09
feature(satnav).
10
bodystyle(saloon).
11
bodystyle(hatchback).
12
bodystyle(estate).
13
bodystyle(minivan).
14
bodystyle(convertible).
15
available(sunroof, hatchback).
16
available(sunroof, minivan).
17
available(reversing_camera, hatchback).
18
available(extra_seats, minivan).
19
available(reversing_camera, saloon).
20
unavailable(sunroof, convertible).
21
unavailable(automatic_tailgate, saloon).
22
unavailable(extra_seats, hatchback).
These clauses have the meanings:
Clause
Meaning
01
Sunroof is a feature.
10
Saloon is a body style.
15
Sunroof is available on a hatchback.
20
Sunroof is unavailable on a convertible.
(a) Sliding doors is a feature that is available on a minivan but unavailable on a hatchback.
Write additional clauses to represent this information.
23 …
24 …
25 …
[3]
(b) Using the variable Options, the goal:
available(Options, saloon)
returns
Options = reversing_camera
Write the result returned by the goal:
available(Options, hatchback)
Options = … [1]
(c) F may be available for B if F is a feature and B is a body style and F is not unavailable for that
body style.
Write this as a rule:
may_choose_option(F, B)
IF …
…
…
… [4]
Question text
10 A declarative programming language is used to allow clients to choose daily activities at the
beach.
01
activity(paddleboarding).
02
activity(sailing).
03
activity(rowing).
04
activity(kayaking).
05
activity(jetskiing).
06
client(stevie).
07
client(antonio).
08
client(henry).
09
client(eliza).
10
client(rebeka).
11
client(danny).
12
client(erik).
13
client(simone).
14
client(petra).
15
client(frankie).
16
choice(petra, rowing).
17
choice(frankie, sailing).
18
choice(erik, sailing).
19
choice(eliza, rowing).
20
choice(stevie, jetskiing).
21
choice(henry, sailing).
22
done(henry, jetskiing).
23
done(rebeka, jetskiing).
24
done(antonio, kayaking).
These clauses have the meanings:
Clause
Meaning
01
Paddle boarding is an activity.
06
Stevie is a client.
16
Petra has chosen rowing.
22
Henry has already done jet skiing.
(a) Jane is a client who would like to choose the activity surfing and she has already done sailing.
Write additional clauses to represent this information.
25 …
26 …
27 …
28 …
[4]
(b) Using the variable List, the goal:
choice(List, rowing)
returns
List = petra, eliza
Write the result returned by the goal:
choice(List, sailing)
List = … [1]
(c) C is a client who would like to choose A if A is an activity and C has not already done A.
Write this as a rule:
may_choose_activity(C, A)
IF …
…
…
… [4]
Question text
8
A declarative programming language is used to represent the features that are available and the
features that are unavailable on different body styles of a car.
01
feature(sunroof).
02
feature(automatic_tailgate).
03
feature(heated_seats).
04
feature(extra_seats).
05
feature(reversing_camera).
06
feature(dashboard_camera).
07
feature(air_conditioning).
08
feature(heated_windscreen).
09
feature(satnav).
10
bodystyle(saloon).
11
bodystyle(hatchback).
12
bodystyle(estate).
13
bodystyle(minivan).
14
bodystyle(convertible).
15
available(sunroof, hatchback).
16
available(sunroof, minivan).
17
available(reversing_camera, hatchback).
18
available(extra_seats, minivan).
19
available(reversing_camera, saloon).
20
unavailable(sunroof, convertible).
21
unavailable(automatic_tailgate, saloon).
22
unavailable(extra_seats, hatchback).
These clauses have the meanings:
Clause
Meaning
01
Sunroof is a feature.
10
Saloon is a body style.
15
Sunroof is available on a hatchback.
20
Sunroof is unavailable on a convertible.
(a) Sliding doors is a feature that is available on a minivan but unavailable on a hatchback.
Write additional clauses to represent this information.
23 …
24 …
25 …
[3]
,
,
(b) Using the variable Options, the goal:
available(Options, saloon)
returns
Options = reversing_camera
Write the result returned by the goal:
available(Options, hatchback)
Options = … [1]
(c) F may be available for B if F is a feature and B is a body style and F is not unavailable for that
body style.
Write this as a rule:
may_choose_option(F, B)
IF …
…
…
… [4]
Question text
10 The pseudocode algorithm shown copies an active accounts text file ActiveFile.txt to an
archive accounts text file ArchiveFile.txt, one line at a time. Any blank lines found in the
active accounts text file are replaced with the words "Account not present" in the archive
accounts text file.
Complete this file-handling pseudocode.
DECLARE Account : STRING
…
OPENFILE "ArchiveFile.txt" FOR WRITE
WHILE NOT …
READFILE "ActiveFile.txt", Account
IF Account = "" THEN
WRITEFILE "ArchiveFile.txt", " … "
ELSE
WRITEFILE "ArchiveFile.txt", …
ENDIF
ENDWHILE
…
CLOSEFILE "ArchiveFile.txt"
[5]
Question text
4
Draw one line from each Object‑Oriented Programming (OOP) term to its most appropriate
description.
OOP term
Description
methods used to return the value of
a property
Encapsulation
the process of putting data and
methods together as a single unit
Getters
methods used to update the value of
a property
Polymorphism
allows methods to be redefined for
derived classes
Setters
enables the defining of a new class
that inherits from a parent class
[4]
Question text
6
(a) Write pseudocode statements to declare the composite data type, TAppointments, to hold
data about patients for a dental clinic. It will include for each patient:
•
name (first name and last name)
•
date of birth
•
telephone number
•
date of last appointment
•
date of next appointment
•
all treatments are complete (yes or no).
…
…
…
…
…
…
…
… [4]
(b) This pseudocode algorithm reads dental records stored in a random file using the user‑defined
data type TAppointments and prints the contents of the file, one record at a time.
Complete this file handling pseudocode:
DECLARE DentalRecord : ARRAY[1:250] OF TAppointments
DECLARE DentalFile : STRING
DECLARE Count : INTEGER
"DentalFile.dat"
DentalFile
OUTPUT "The file ", DentalFile, " contains these records:"
OPENFILE …
…
1
REPEAT
SEEK DentalFile, Count
…
OUTPUT DentalRecord[Count]
Count + 1
Count
… (DentalFile)
…
[5]
Question text
2
A declarative language is used to represent the following facts about cats.
01
type(leopard, wild).
02
type(lion, wild).
03
type(cheetah, wild).
04
type(savannah, hybrid).
05
type(persian, domestic).
06
07
hair(leopard, medium).
08
hair(lion, short).
09
hair(cheetah, medium).
10
hair(savannah, medium).
11
hair(persian, long).
12
13
spots(leopard, yes).
14
spots(lion, no).
15
spots(cheetah, yes).
16
spots(savannah, yes).
17
spots(persian, no).
These clauses have the following meaning:
Clause
Meaning
01
A leopard is a type of wild cat.
08
A lion has short hair.
16
A savannah has spots.
(a) More facts are to be included. A caracal is a wild cat with short hair.
Write the additional clauses to record these facts.
18 …
19 …
[2]
(b) Using the variable Cat, the goal:
hair(Cat, medium)
returns
Cat = leopard, cheetah, savannah
Write the result returned by the goal:
hair(Cat, long)
Cat = … [1]
(c) (i)
Write the goal, using the variable Pet, to find all the domestic cats.
…
… [1]
(ii)
Write the goal, using the variable WildSpotty, to find all the wild cats with spots.
…
…
…
… [2]