Skip to content

Labs · 9618 A2 20.1

Classes and Objects

Make objects from classes, call their methods and see encapsulation, inheritance and polymorphism at work, in 9618 pseudocode.

6 levelsFree bench

In the exam

9618/31 October/November 2022 · Question 11 · 8 marks

(a) Define these OOP terms: instance, inheritance, polymorphism. (b) Complete the pseudocode for the class Car to enable objects to be created: string attributes for the make, model, body type and fuel type, and an integer attribute for the number of cars of that type built. The attributes must be available only through the methods of the class.

Points that gain marks

  • (a) Instance: an occurrence of an object; a specific object based on the class.
  • Inheritance: defining a new class of objects that has all the attributes and methods of the parent class.
  • Polymorphism: the same method takes on different behaviours depending on the class; methods can be redefined for derived classes.
  • (b) CLASS Car and ENDCLASS.
  • Four PRIVATE declarations, using the identifiers in the assignments.
  • A constructor header that uses CarBodyType.
  • Two assignments, using CarMake.
  • The same identifier for the car model in the constructor and in the Model assignment.

In this lab: Level 5 is part (b); level 6 uses the definitions.

9618/32 May/June 2023 · Question 4 · 4 marks

Draw one line from each OOP term (encapsulation, getters, polymorphism, setters) to its most appropriate description.

Points that gain marks

  • Encapsulation: the process of putting data and methods together as a single unit.
  • Getters: methods used to return the value of a property.
  • Polymorphism: allows methods to be redefined for derived classes.
  • Setters: methods used to update the value of a property.

In this lab: Level 6.

More real experiments

Log in or create account

IGCSE, A-Level & AP