UNIVERSITY EXAMINATIONS: 2013/2014
ORDINARY EXAMINATION FOR THE BACHELOR OF SCIENCE
IN INFORMATION TECHNOLOGY/BUSINESS INFORMATION
TECHNOLOGY
BIT2108 OBJECT ORIENTED PROGRAMMING
DATE: AUGUST, 2014 TIME: 2 HOURS
INSTRUCTIONS: Answer Question ONE and any other TWO
QUESTION ONE
a) Explain the concept of object technology as used in application development.
(4 Marks)
b) Explain at least five features in any o bject oriented programming language that
support object technology
(10 Marks)
c) With help of a sample program describe the structure of C++ program.
(8 Marks)
d) Explain how the concept of client-server is used in C++ program.
(4 Marks)
e) Differentiate between structure and class as used in C++. Give examples to support
your argument.
(4 Marks)
QUESTION TWO
a) Debug the following program.
#include<ionstream.r>
main ( )
{
cout<<”enter two nubmers:”;//prompt
cin>> number1; //Read number
float number 1, number 2,sum, average;
cin>>number 2; //from keyboard
average=sum/2;
sum=number 1+number 2;
2
void;
cout<<”sum=”<<sum<<”\n”;
cout<<”average=”<<average<<”\n”;
}
}
(5 Marks)
b) Find the errors in the following function prototype.
i). Float average(a,b);
ii). Int mul(int a,b);
iii). Int display();
iv). Void vect(int&v,int&size);
v). Void print(float data[],size=20); (5 Marks)
c) State with a reason whether the following statements are true or false.
(i) Function argument is a value returned by the function to the calling
program.
(ii) When a function returns a value, the entire function can be assigned to
variable.
(iii) When argument is passed by value the function works with the original
arguments in the calling program.
(iv) A function can return a value by reference.
(v) When argument is passed by reference, a temporary variable is created
in the calling program to hold the argument value. (5 Marks)
d) Briefly discuss how each of the following visibility modifiers affects inheritance
of member elements in derived classes.
(i) Private (2 Marks)
(ii) Public (1 Marks)
(iii) Protected (2 Marks)
QUESTION THREE
a) What is operator overloading and why do we use this concept. Give the general
syntax that is used to implement operator overloading. (4 Mrks)
b) Write a program with base class animal with features, which can be inherited by class
Human being and class domesticated animal. Create instances from all classes to
demonstrate aspect of inheritance. (10 Marks)
c) Explain using an example how classes help to achieve program modularization.
(6 Marks)
QUESTION FOUR
a) Write methods for bank operations such as recording customer’s details, recording
deposits and withdrawals. (Methods are declared within a class, main() is outside the
class)
Program should have the following:
Methods
Get details
Make deposit
Make withdrawals
Enquiry(optional)
Main() (10 Marks)
b) Explain how you could modify the above program to achieve data hiding.
(5 Marks)
c) Differentiate between intrinsic and user defined data type as used in C++. Give two
examples in each case. (5 Marks)
QUESTION FIVE
a) Write a program to capture student’s details. In your program include the following.
i). A constructor function
ii). A destructor and
iii). Other member function you may find necessary (15 Marks)
b) Differentiate between the following type of function as used in C++
(i) Inline function
(ii) Friend function
(iii) Constructor function
(iv) Virtual function
(v) Recursive function (5 Marks)