Mr.
Mahmoud Moussa                                                                       A2 CS 9618
                      Chapter 27- OOP Questions
Question 1
An application is to be implemented. An object-oriented programming (OOP) language will be
used. Explain how OOP uses classes and objects. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
An application is to store and process data for major event venues. Venues include football and
cricket stadia and theatres. Three classes are to be designed as shown by the inheritance diagram
below.
Explain what is meant by inheritance. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
www.mahmoudmoussa.com                                                                               1
Mr. Mahmoud Moussa                                                                     A2 CS 9618
All venues have the venue name and address recorded. A theatre has recorded:
      the number of seats
      a list of the types of event staged (such as play, rock concert)
      whether or not the theatre has a restaurant.
A stadium has recorded
      a list of the sports played (such as football, cricket and athletics)
      a list of the names of any teams that play their home fixtures here
      the capacity
      whether the stadium is ‘seating-only’.
Draw the class diagram showing the classes and properties given. Do not attempt to include any
methods on the class diagram. [4]
www.mahmoudmoussa.com                                                                            2
Mr. Mahmoud Moussa                                                                  A2 CS 9618
Question 2
The following terms are used in object-oriented programming (OOP) and design. Give an
appropriate definition for each term. [5]
Encapsulation
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Class
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Instance
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Method
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Attribute
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
www.mahmoudmoussa.com                                                                        3
Mr. Mahmoud Moussa                                                                     A2 CS 9618
Question 3
A company’s website is maintained by several employees. The company has a number of
permanent employees whose job title is either ‘programmer’ or ‘web designer’. An agency supplies
the company with contract employees when there is a need for specialist skills. Contract employees
have the job title ‘graphic designer’ or ‘technical author’.
Employees have recorded:
     employee reference number
     date first worked for company
Contract employees have recorded:
     agency they were supplied by
     agreed hourly rate of pay
     job role
Permanent employees have recorded:
     salary grade
     courses attended
Programmers have recorded:
     programming languages used
Web designers have recorded:
     mark-up languages used
This scenario is to be implemented using object-oriented programming.
Draw the class diagram using the classes: Employee, Contract, Permanent, Programmer,
WebDesigner. Show properties only for the given data. [8]
www.mahmoudmoussa.com                                                                            4
Mr. Mahmoud Moussa                                         A2 CS 9618
Question 4
Define these Object-Oriented Programming (OOP) terms [3]
Instance
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Inheritance
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Polymorphism
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
www.mahmoudmoussa.com                                               5
Mr. Mahmoud Moussa                                                                     A2 CS 9618
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. [5]
CLASS Car
       PRIVATE Make : STRING
       PRIVATE ………………………………………………………………………………………………………………
       ………………………………………………………………………………………………………………
       ………………………………………………………………………………………………………………
       ………………………………………………………………………………………………………………
       PUBLIC PROCEDURE NEW (CarMake : STRING,
       ………………………………………………………………………………………………………………………………………………………………)
       Make ← ………………………………………………………
       Model ← ………………………………………………………
       BodyType ← CarBodyType
       Fuel ← ""
       NumberBuilt ← 0
       ENDPROCEDURE
       getFuel()
       getNumberBuilt()
………………………………………………………
www.mahmoudmoussa.com                                                                           6
Mr. Mahmoud Moussa                                          A2 CS 9618
Question 5
Define these Object-Oriented Programming (OOP) terms: [3]
Encapsulation
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Getter
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Setter
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
www.mahmoudmoussa.com                                                7
Mr. Mahmoud Moussa                                                                         A2 CS 9618
A school has a program written using OOP to maintain its staff and student records. The object
SubstituteTeacher allows the details of the school’s substitute teachers to be stored. This includes
their full name, telephone number and whether or not they are in school today. For example:
Complete the diagram for the object SubstituteTeacher, including appropriate properties and their
getters and setters. [5]
www.mahmoudmoussa.com                                                                                  8
Mr. Mahmoud Moussa                                                                      A2 CS 9618
Question 6
A program is to be written using Object-Oriented Programming (OOP) for a shop that sells knitting
yarn. There are three types of yarn: acrylic, wool or mix
The following data are stored for each type
      Name
      Colour
      Batch code
      Weight
      Number of balls of yarn in stock (can be edited)
      Type of yarn
The following statements apply to yarn
      Acrylic can be soft or not soft.
      Wool can be lamb, merino or alpaca.
      Mix contains a percentage of acrylic
Each type of yarn has a method that will display all the information about the yarn.
Complete this class inheritance diagram to show the properties, methods and inheritance. [4]
www.mahmoudmoussa.com                                                                            9
Mr. Mahmoud Moussa                                                             A2 CS 9618
Describe what is meant by the terms properties, methods and inheritance. [3]
Properties
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Methods
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Inheritance
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
www.mahmoudmoussa.com                                                                 10