You are on page 1of 3

W1-2-60-1-6

JOMO KENYATTA UNIVERSITY OF AGRICULTURE AND


TECHNOLOGY
UNIVERSITY EXAMINATIONS 2020/2021

YEAR 2 SEMESTER 1 EXAMINATIONS FOR THE DEGREE OF BACHELOR OF


BUSINESS INFORMATION TECHNOLOGY/BACHELOR OF SCIENCE IN
INFORMATION TECHNOLOGY
ICS 2104: OBJECT ORIENTED PROGRAMMING I
DATE: AUGUST 2021 TIME: 2 HOURS
INSTRUCTIONS:
This paper consists of FIVE questions. Attempt question ONE (Compulsory) and any other
TWO questions

QUESTION ONE

a) Choose FIVE features of the object-oriented paradigm. Describe what they are, why they
are important and give an example of EACH feature, either with code or with a diagram
(10 marks)

In an object-oriented programming language, write code to implement the class diagram


above. Within your code provide a default constructor for each class that sets the
variables to appropriate initial values. (10 marks)

c) Explain the difference between an object in an object-oriented language and a variable in


a structured programming language. (4 marks)

d) Explain why encapsulation is a key concept when working with objects. (3 marks)

e) When would private and protected class members be used in an object-oriented program?
Clearly distinguish between them. (3 marks)

1
QUESTION TWO

a) What is a constructor? List out characteristics of constructors (5 marks)

b) A function add takes 2 parameters of typer double and returns their sum.

i) Declare the function


ii) Define the function
iii) Call the function in main function (5 marks)

c) The class diagram below represents a Van Hire system that records the hiring of van. In
an object-oriented programming language, write code to implement the class diagram
below. Within your code provide a default constructor and a destructor for each class.
(10 marks)

QUESTION THREE

a) Write a C++ program to explain the use of the IF..ELSE statement in any C ++ program.
(4 marks)

b) What is overriding in C++? Give an example (4 marks)

c) Explain what is type conversion and how it can be achieved in C++? (4 marks)

d) What is a Manipulator? Explain any three types of C++ manipulators. (4 marks)

e) With the help of a good code example; explain the difference between local and global
variables. (4 marks)

QUESTION FOUR

a) Explain Virtual Base Class with an Example (2 marks)

b) Write code to open a file and write some data into the file (6 marks)

2
c) Define dynamic binding and give an example of how it is implemented in OOP (4 marks)

d) Design and implement a class “Employee” using C ++. The class should have the
following features:

 It should store the employee ID, name, department and present total salary of an
employee.
 The class should have a function that can input the values in an object.
 The class should also have a function that can display the content of an object.
 The class should have another function that takes ID as a parameter and displays the
department of the person whose employee ID is same as the ID given. Demonstrate all
the functions by creating an array of five “employee” objects in the main () function.
(8 marks)

You might also like