Define these Object-Oriented Programming (OOP) terms: Instance Inheritance Polymorphism
- (a)Define these Object-Oriented Programming (OOP) terms: Instance Inheritance Polymorphism[3]
- (b)In OOP, a class contains attributes and methods. Complete the pseudocode for the class Car to enable objects to be created. The class needs to include: • string attributes to store the make, model, body type and fuel type • an integer attribute to store the number of cars of that type built. The attributes must be available only through the methods of the class. CLASS PRIVATE Make : STRING PRIVATE PUBLIC PROCEDURE New (CarMake : STRING, Make ← Model ← BodyType ← CarBodyType Fuel ← "" NumberBuilt ← 0 ENDPROCEDURE GetFuel () GetNumberBuilt() .)[5]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2022). The mark or mark type is shown in brackets.
- [3] One mark for each correct OOP term definition:
- • Instance – an occurrence of an object // a specific object based on the class // an instantiation of a class.
- • Inheritance - the capability of defining a new class of objects that has all the attributes and methods from a parent class.
- • Polymorphism – allows the same method to take on different behaviours depending on which class is instantiated // methods can be redefined for derived classes.
- [5] One mark for each point:
- • Car and ENDCLASS
- • Four declarations – must use the identifiers used in the assignments
- • Constructor header – must use CarBodyType
- • Two assignments – must use CarMake
- • Constructor identifier for the car model and the identifier in the Model assignment statement match
- 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() ENDCLASS
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →