UNIVERSITY EXAMINATIONS: 2017/2018
EXAMINATION FOR DEGREE OF BACHELOR SCIENCE/BUSINESS
INFORMATION TECHNOLOGY
BIT 2108/BBIT 203: OBJECT ORIENTED PROGRAMMING
MODE: FULL TIME/PART TIME/DISTANCE LEARNING
ORDINARY EXAMINATIONS
DATE: NOVEMBER, 2018 TIME: 2 HOURS
INSTRUCTIONS: Award marks for Question ONE and any other TWO questions
QUESTION ONE [30 MARKS]
a) Discuss the concept of encapsulation as used in object oriented programming.
4 Marks
b) Describe any FIVE key features of object oriented programming(OOP).
5 Marks
c) Briefly describe the concept of message passing in object oriented systems.
3 Marks
d) In the context of object oriented programming, an object can be defined as an entity that
keeps together state and behaviors. Describe THREE desirable qualities of an object.
3 Marks
e) Encapsulation supports information hiding by making use of the three access specifiers of a class
namely public, private and protected. Briefly explain these access specifiers.
6 Marks
f) Explain any FOUR distinct differences between structured programming and object oriented
programming paradigms.
8 Marks
QUESTION TWO [20 MARKS]
a) Define the concept of class as used in object oriented programming.
4 Marks
b) Using C++ program, create a class Employee with data members employeeID, name, designation and
salary. Write methods getEmployee ()-to take user input, showOrder ()-to display grade of employees
based on salary, showEmployee () to display employee details. Assume there are 10 employees
whose details are to be captured and displayed by the program.
10 Marks
c) Explain the differences between class and structure.
6 Marks
QUESTION THREE [20 MARKS]
a) Briefly explain the concept of a method in object oriented programming.
2 Marks
b) Explain the difference between mutator and accessor methods
4 Marks
c) Differentiate between a method prototype and method signature.
4 Marks
d) Briefly explain the concept of a constructor in object oriented programming.
3 Marks
e) Write a C++ program to use to methods getNumbers () ,to read two numbers keyed in by the
user and swapNumbers () , to swap the two numbers then display values on screen.
7 Marks
QUESTION FOUR [20 MARKS]
a) Define pure virtual functions. Write a C++ program to illustrate pure virtual functions.
10 Marks
b) Differentiate between function template and class template in C++. Give an example for
each.
5 Marks
c) Discuss the coercion polymorphism and how it is implemented in C++.
5 Marks
QUESTION FIVE [20 MARKS]
a). Using function write a program in C++ to take two arrays of integer numbers and multiply
each corresponding values and put the result in a third array.
6 Marks.
b). Inheritance enables new classes to receive (or inherit) the properties and methods of existing
classes. Discuss the following types inheritance:
i. Single inheritance
ii. Multilevel inheritance
iii. Hierarchical inheritance
iv. Multiple inheritance
4 Marks
c). You are required to write a C++ program based on the following class definition:
class date {
private: int day; // from 1 to 31
private: int month; // from 1 to 12
private: int year; // from 2018 upwards
public: void advance(); // move to next day
};
i. Implement a constructor that initializes new objects of date class to be set to the 1st of
January 2018.
4 Marks
ii. Implement setters for day, month and year.
3 Marks
iii. Implement the advance method, which moves to the next day, ensuring that all data
members are updated appropriately.
3 Marks