BIT2108  BBIT203  OBJECT ORIENTED PROGRAMMING3 . KCA Past Paper

UNIVERSITY EXAMINATIONS: 2016/2017
EXAMINATION FOR THE DEGREE OF BACHELOR OF SCIENCE IN
INFORMATION TECHNOLOGY
BIT2108 BBIT203 OBJECT ORIENTED PROGRAMMING
FULL TIME/PART TIME
SPECIAL /SUPPLEMENTARY EXAMINATION
DATE: JULY, 2017 TIME: 2 HOURS
INSTRUCTIONS: Answer Question One & ANY OTHER TWO questions.

QUESTION ONE [30 MARKS]
a) Answer True or False for the following C++ Claims (1*10 Marks)
i.) In general, switch is faster than if-else.
ii.) By default the members of a class are private.
iii.)The length of a string object s1 can be obtained using the expression s1.length.
iv.)All functions in an abstract base class must be declared pure virtual.
v.) Throwing an exception always causes program termination.
vi.)The expression for (;;) is the same as a while loop with a test expression of true.
vii.) We cannot use the % operator to compute the remainder of an array index.
viii.) There is no direct mechanism to locate a sub-string in a string.
ix.)Static member functions are independent of objects.
x.) If no overloaded operators are provided, C++ automatically provides them.
b) Match word (Y) and phrases (X) from the following table (1*10 Marks)

c) From the words in the table below, fill the blank spaces in the statement that follow
(1* 10 Marks)


A. encapsulation B. ios C. onevalue
D. class E. break F. classlibrary
G. delete H. multipleinheritance I. twovalues
J. Scope-resolutionoperator K. datahiding L. virtualfunctions
i.) If we do not write the ________ statement, even if a condition matches, switch continues
execution.
ii.) A function is allowed to return ________.
iii.)The ________ usually resolves ambiguities.
iv.)A template argument is preceded by the keyword ________.
v.) A group of related classes, supplied as a separate product, is often called a(n) ________.
vi.)The ________ operator is used to release memory allocated dynamically.
vii.) ________ allows a derived class to have more than one base class.
viii.) C++ achieves polymorphism through ________.
ix.)The base class for most stream classes is the ________ class.
x.) The wrapping up of data and functions into a single unit is called ________.
3
QUESTION TWO [20 MARKS]
i.) What is object oriented programming? How is it different from procedure-oriented
programming?
(6 Marks)
ii.) What is the difference between the while and do-loops with respect to the respect to the
number of times the loop executed?
(6 Marks)
iii.)What is the main advantage of passing arguments by reference? Explain this with an
example.
(8 Marks)
QUESTION THREE [20 MARKS]
i.) What is operator overloading? Illustrate operator overloading concept to concatenate
strings.
(6 Marks)
ii.) What is a pointer? Explain the difference between the address stored in a pointer and the
value at that address.
(8 Marks)
iii.)Why do we need virtual functions?
(6 Marks)
QUESTION FOUR [20 MARKS]
i.) Explain why do we need to use constructors? Explain a copy constructor with an
example.
(8 Marks)
ii.) What is an exception? How is an exception handled in C++?
(6 Marks)
iii.)Write a program that illustrates the application of multiple catch statements.
(6 Marks)
QUESTION FIVE [20 MARKS]
a) What does the following statement do? (1*4 Marks)
i.) *ptr+=1;
ii.) ++*ptr;
iii.)(*ptr)++;
iv.) *ptr++;
b) What do you understand by the term Abstract Data Type?
(6 Marks)
c) Write a program to show that the declaration of a class ‘Rectangle’, which derives from
the class ‘square’, which in turn derives from the class ‘shape’.
(10 Marks)

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

Written by