BIT2108  BBIT203  OBJECT ORIENTED PROGRAMMING.

UNIVERSITY EXAMINATIONS: 2018/2019
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: MARCH.2019 TIME: 2 HOURS
INSTRUCTIONS: Award marks for Question ONE and any other TWO questions

QUESTION ONE [30 MARKS]
a) Differentiate between the following
i. Object oriented and object based programming languages
ii. Class and Object
iii. Method overriding and method overloading
iv. Constructor and destructor member methods
8 Marks
b) Preprocessor are commands that are executed before any other statement in your program.
Describe any two such preprocessors used in C++ programming.
4 Marks
c) Discuss the major drawbacks of structured Languages that necessitated advancement of
object oriented programming.
6 Marks
d) Define what a pointer is and describe two operators associated with it operation.
3 Marks
e) Create a structure person with members’ id, age, height and weight. Write a program that
shows how this structure is implemented in main. In main, the programs also compute the
Body Mass Index (BMI) given as weight (kg)/height2 (m2). The data is input by the user
through program prompting and re-echo the same on the screen in an appropriate format.
9 Marks
QUESTION TWO [20 MARKS]
a). Describe the concept of inline function in C++.
3 Marks
b). Write a C++ program to find the multiplication values and the cubic values using inline
function.
8 Marks
c). Write a program in C++ that calculates and displays the weekly salary for an employee who
earns Kshs 2500 an hour, works 20 regular hours, 10 overtime hours, and earns time and
one-half (wage * 1.5) for overtime hours worked. Create a separate method to do the
calculation and return the result to be displayed. Your program should contain a class that
holds the employee details indicated as well as the method to do the computation
9 Marks.
QUESTION THREE [20 MARKS]
a) Write a C++ program that displays an invoice of six items. It should contain the item name,
quantity, price, and total cost for each item. It also contains methods to get and show item
name, quantity, and price. Objects are created in main and invoices printed.
6 Marks
b) Describe the concept of template classes in C++. Give an example.
5 Marks
c) Describe the concept of function abstraction in object oriented programming.
3 Marks
d) Describe how function abstraction can be realized in C++.
6 Marks.
QUESTION FOUR [20 MARKS]
a) Predict the output of the program below and explain your answer.
#include <iostream>
using namespace std;
class vector{
public: double x,y;
double surface (){
double s;
s = x * y;
if (s < 0)
s = -s;
return s;
}
};
int main (){
vector a;
a.x = 3;
a.y = 5;
cout << “The surface of a: ” << a.surface() << endl;
return 0;
}
6 Marks
b) Describe two advantages and two disadvantages of encapsulation in object oriented
programming.
4 Marks
c) Describe the concept of pure abstract class. Write a simple code in C++ to support your
description.
6 Marks.
d) Describe the four primary data types in C++. In your explanation highlight on maximum
memory size, values stored, and range of the values.
4 Marks
QUESTION FIVE [20 MARKS]
a) Explain three ways in which the sub-classes extend existing classes in C++.
6 Marks
b) Discuss three disadvantages of inheritance as used in object oriented programming.
6 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. When argument is passed by reference, a temporary variable is created in the
calling program to hold the argument value.
8 Marks

(Visited 109 times, 1 visits today)
Share this:

Written by