Dit-Sep-2022-Object Oriented Programming
Dit-Sep-2022-Object Oriented Programming
Dit-Sep-2022-Object Oriented Programming
STAGE 2 TERM 1
EXAMINATION
APRIL 2024 SERIES
INSTRUCTIONS
Candidates should check the question paper to ascertain that all pages are printed as indicated and
that no questions are missing
Shadrack Kodondi
QUESTION ONE
e) Write a program in C++ that allows a user to enter the dimensions of a right
angled tringle and outputs its perimeter. Use appropriate data members and
one function (3
Marks)
QUESTION TWO
2
QUESTION THREE
b.) Explain the purpose of using the namespace std in C++ programs (2
marks)
c.) List any FOUR derived data types as used in C++ program (2
marks)
d.) State one advantage and one disadvantage of using inline functions in OOP
(2 marks)
e.) Using sample code, Implement a class named rect from the base class Sqr
(3
Marks)
f.) using code samples, demonstrate three different types of inheritance (6
marks)
g.) Differentiate between derived class and parent class as used in object-oriented
programming (2Marks)
QUESTION FOUR
a.) Explain the circumstances under which the following data types are most
applicable in OOP (2 marks)
i.) struct
3
ii.) class
b.) Explain the term encapsulation as used in OOP (2 marks)
d.) Describe the circumstances under which the following C ++ program elements
are most applicable:
i) Scope resolution operator (2 marks)
ii) Object parameter (2 marks)
QUESTION FIVE
The following code was written by a student. Use it answer the questions that
follow. Identify any THREE bugs in the code snippet and rewrite the code by
4
correcting the errors
(2 marks)