0% found this document useful (0 votes)
14 views2 pages

Bit 2108 Bbit 203 Bac 2101 Bisf 2101 BSD 2102 Object Oriented Programming

Uploaded by

cheburetdaisy65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Bit 2108 Bbit 203 Bac 2101 Bisf 2101 BSD 2102 Object Oriented Programming

Uploaded by

cheburetdaisy65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

UNIVERSITY EXAMINATIONS: 2021/2022

EXAMINATION FOR BACHELOR OF SCIENCE IN INFORMATION


TECHNOLOGY/BUSINESS I.TAPPLIED COMPUTING/ INFO SECURITY
AND FORENSIC/ SOFTWARE DEV ELOPMENT
BIT 2108/BBIT 203/BAC 2101/BISF 2101/BSD 2102:
OBJECT ORIENTED PROGRAMMING
MODE: FULL TIME/PART TIME/DISTANCE LEARNING
ORDINARY EXAMINATIONS
DATE: DECEMBER, 2021 TIME: 2 HOURS

INSTRUCTIONS: Answer QUESTION ONE and ANY OTHER TWO questions

QUESTION ONE 20 MARKS


a) Describe FOUR principles of an object oriented program. 4 Marks
b) Differentiate between method overloading and method overriding 4 Marks
c) Create a base class named Rectangle that includes data members for the length and width of a
Rectangle, as well as functions to assign and display those values. Derive a class named
Block that contains an additional data member to store height, and contains functions to
assign and display the height. Write a main()function that demonstrates the classes by
instantiating and displaying the values for both a Rectangle and a Block. 12 Marks

QUESTION TWO [15 MARKS]


a). You are given a UML class diagram below, write a C++ program to implement this design.
The Get() method will read values of Num1 and Num1 then pass them to Multiply(),
Divide() and Sum() methods. Each of these class methods will perform calculation and
assign result to variable called ans which is then displayed.
7 Marks
b). Write a C++ program that reads a word from the keyboard, stores it in a string, and checks
whether the word is a palindrome. A palindrome reads the same from left to right as from
right to left e.g. “omo”. 8 Marks

QUESTION THREE [15 MARKS]


You need to create a class called “Distance” with feet and inches as data members. The class will
have three member functions: a member function to input distance, member function to output
distance and a member function to add two distance objects.
a) Create a UML class diagram for this case. 7 Marks
b) Write a C++ program to implement the UML class design. Hint: Use main function to create
objects of “Distance” class, input two distances and output the sum. 8 Marks

QUESTION FOUR [15 MARKS]


a) Write a program that defines a shape class with a constructor that gives value to width and
height. The define two sub-classes triangle and rectangle, that calculate the area of the
shape area (). In the main, define two variables a triangle and a rectangle and then call the
area() function in this two variables. 7 Marks
b) Using a pure virtual function, write a C++ programming that would implement the class
hierarchy shown in the figure below. The program should initialize the dimensions of the
shape as a=14 and b=8 and output the area of the respective shapes. Hint: Area of a
triangle=1/2(a*b) while that of a rectangle=(a*b).

8 Marks

You might also like