Cambridge A2 Level Computer Science 9618 · 20.1 Programming Paradigms

Q8 · 9618/32/O/N/22 Q10

Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2.

Q89618/32/O/N/22original Q10Structured · 6 marks
Question 10 from 9618/32/O/N/22

Worked solution

(a)

Write one definition for each term:

Encapsulation: putting the properties and methods inside a class, which hides the data from users [1]

Getter: a method that returns the value of a property [1]

Setter: a method that updates the value of a property [1]

(b)

Add the missing property (Telephone), then a setter and getter for each of the three properties.

SubstituteTeacher
-----------------
SubName : STRING
Telephone : STRING
InSchool : BOOLEAN
-----------------
SetSubName(StaffName : STRING)
SetTelephone(Tel : STRING)
SetInSchool(Present : BOOLEAN)
GetSubName()
GetTelephone()
GetInSchool()

Properties correct: Telephone : STRING added [1]

Setters correct: SetSubName and SetInSchool added [1]

Getters correct: GetTelephone() and GetInSchool() added [1]

KEY IDEAPrivate properties are read with getters and changed with setters, all kept together in the class (encapsulation).
TOTAL 6 marks

Official mark scheme

Mark scheme for 9618/32/O/N/22 question 10
VIDEO
▶ Whole paper

Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.