Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2.
Write one definition for each term:
Instance: a specific object made from a class (an instantiation of the class) [1]
Inheritance: defining a new class that gets all the attributes and methods of a parent class [1]
Polymorphism: the same method can behave differently depending on the class used (methods can be redefined in derived classes) [1]
Name the class, declare the other four PRIVATE attributes, add the constructor parameters, assign them, and close the class.
CLASS Car
PRIVATE Make : STRING
PRIVATE Model : STRING
PRIVATE BodyType : STRING
PRIVATE Fuel : STRING
PRIVATE NumberBuilt : INTEGER
PUBLIC PROCEDURE NEW(CarMake : STRING, CarModel : STRING, CarBodyType : STRING)
Make ← CarMake
Model ← CarModel
BodyType ← CarBodyType
Fuel ← ""
NumberBuilt ← 0
ENDPROCEDURE
GetFuel()
GetNumberBuilt()
ENDCLASSCLASS Car and ENDCLASS [1]
Four PRIVATE declarations (Model, BodyType, Fuel as STRING and NumberBuilt as INTEGER) using the identifiers in the assignments [1]
Constructor header with the parameter CarBodyType [1]
Assignments Make ← CarMake and Model ← CarModel [1]
The constructor parameter for the model matches the identifier in the Model assignment [1]
▶ Whole paper
Video solution of the whole paper · by MAK CS. 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.