Cambridge A2 Level Computer Science 9618 · 13.1 User-defined data types

Q4 · 9618/32/M/J/22 Q1

Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 1 of 3.

Q49618/32/M/J/22original Q1Structured · 9 marks
Question 1 from 9618/32/M/J/22

Worked solution

(a)

BuildingRegister.BuildingID ← 1067
BuildingRegister.BuildingGroup ← "house"

BuildingID assigned 1067 [1]

BuildingGroup assigned the text house in quotes [1]

(b)(i)

TYPE BuildingType = (house, bungalow, apartment, farm)

TYPE BuildingType = [1]

(house, bungalow, apartment, farm) [1]

(b)(ii)

DECLARE BuildingGroup : BuildingType

Field declared with the type BuildingType [1]

(b)(iii)

House is now an enumerated value, so no quotes.

BuildingRegister.BuildingGroup ← house

Assignment with house and no quotes [1]

(c)(i)

PRIVATE OwnerName : STRING

PRIVATE OwnerName : STRING [1]

(c)(ii)

Private properties can only be accessed by the class's own methods [1]

This is encapsulation: the data is hidden, so other code cannot change it by mistake [1]

KEY IDEAEnumerated values are written without quotes, and PRIVATE properties are hidden to give encapsulation.
TOTAL 9 marks

Official mark scheme

Mark scheme for 9618/32/M/J/22 question 1
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.