Get premium membership and access revision papers, questions with answers as well as video lessons.

Object Oriented Programming I Question Paper

Object Oriented Programming I 

Course:Business Administration

Institution: Kenya Methodist University question papers

Exam Year:2008



Answer Question ONE (Compulsory) and any other TWO Questions
Question 1
(a)
Define the term object oriented programming, giving one example of an OOP language
(2 marks)
(b)
Distinguish between the following terms:
(i)
Object and classes
(2 marks)
(ii)
Superclass and subclass
(2 marks)
(iii)
Data members and function members
(2 marks)
(iv)
Private and public members
(2 marks)
(c)
Outline two characteristics of each of the following
(i)
Constructor function
(ii)
Friend function
(4 marks)
(d)
Using a simple diagrams where applicable discuss the following forms of inheritance
(i)
Single inheritance
(ii)
Multiple inheritance
(4 marks)
(e)
Outline FOUR benefits of object Oriented Programming Languages
(4 marks)
(f)
Write a function prototype for a function named test that accepts two parameters, an int
and char, and returns a float
(4 marks)
(g)
Declare a class called rectangle which has two private data members length and width
and two public member functions called input() and output()
(4 marks)
1
Question 2
(a)
Define the term function
(1 mark)
(b)
Using an example briefly define the following terms as used in C++
(i)
Function call
(ii)
Function prototype
(iii)
Function definition
(3 marks)
(c)
Explain any four advantages of using a function
(4 marks)
(d)
Ken tank company Ltd manufacturers water containers of different shapes. The most
common containers include spherical, rectangular and cylindrical tanks.
Required:
Write an overloaded function Volume () to compute the different volumetric capacities of
the three containers.
Hint:
Volume of a cylinder = pr
2
h
Volume of a rectangle = l * w * h
Volume of a sphere = 4 pr
3
/3
(12 marks)
Question 3
You have been asked to develop a program for printing out a simple telephone bill. The program
will input the following details:
?
Name of customer
?
Address
?
Telephone Number
?
Previous meter reading
?
Current meter reading
The program will calculate the number of units used, and compute the bill charged using the
following rates:
No. OF UNITS
COST PER UNIT (Kshs)
> 0 and <= 100
2.50
>100 and <=200
2.25
>200 and <=350
1.90
>350
1.65
The program will then print out the bill details as follows:
?
Name of customer
?
Address
?
Telephone Number
?
Previous meter reading
2
?
Current meter reading
?
Consumption(Units Consumed)
?
Bill to Pay
(20 marks)
Question 4
Professional university library maintains an inventory of books. The list includes details like
Author, price, title, publisher, acc_no, and number of copies of each book.
Whenever new books are purchased the librarian adds details into the database. The chief
librarian occasionally requests for a list of all books in the database.
Required:
Assuming the database to be an array of ten (10) books, construct a class called book with
suitable data members and member functions to:
(i)
Insert a new book record into the database
(ii)
Display a list of all books in the database
(iii)
Write a main function to test the program
(20 marks)
Question 5
A company stores the information of her employees in a database. There are only three kinds of
employees represented. Managers manage, scientists perform research to develop better widgets,
and laborers operate the dangerous widget-stamping presses.
The database stores a name and an employee identification number for all employees, no matter
what category they are. However, for managers, it also stores their titles and golf club dues. For
scientists it stores the number of scholarly articles they have published. Laborers need no
additional data beyond their names and numbers.
Show how this model can be represented diagrammatically. Write a program which will
implement the hierarchy described above. The program starts with a base class employee. This
class handles the employee’s last name and employee number. From this class three other classes
are derived: manager, scientist, and laborer. The manager and scientist classes contain additional
information about these categories of employee, and member functions to handle this
information.
(20 marks)
3






More Question Papers


Popular Exams



Return to Question Papers