9618/31/M/J/22 question 7: worked solution (May/June 2022, paper 31)
Show as plain textHide plain text
Cambridge A2 Level Computer Science 9618 · 20.1 Programming Paradigms Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2. Q4 9618/31/M/J/22 original Q7 Structured · 11 marks Worked solution (a) Acrylic and Wool each need one extra property and a YarnInfo() method. All three classes inherit from Yarn. Class Properties Methods Acrylic Soft: BOOLEAN Constructor(), YarnInfo() Wool WoolType: STRING Constructor(), YarnInfo() Mix Percentage: INTEGER Constructor(), YarnInfo() Acrylic has the property Soft : BOOLEAN [1] Wool has the property WoolType with a suitable data type, for example STRING [1] Acrylic and Wool both have the method YarnInfo() [1] At least one inheritance arrow from Acrylic, Wool or Mix up to Yarn [1] All three arrows (Acrylic, Wool and Mix to Yarn) drawn [1] (b) Write one short description for each term: Properties : the data items (attributes) of an object, defined in a class [1] Properties also have data types (characteristics) [1] Methods : the procedures or functions (programmed instructions) in a class [1] Methods implement the behaviour and act on the properties [1] Inheritance : the methods and properties of one class (the super / base class ) are contained in that class [1] They are made available to, and reused by , another class (the derived class ) [1] KEY IDEA A class holds properties and methods, and derived classes inherit them from a base class while adding their own. TOTAL 11 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.