OOP.docx
- 1. ©2023 Kendege Technical & Vocational College Page 1
2920/203
OBJECT ORIENTED PROGRAMMING
JUNE 2023
TIME: 3 HOURS
KENDEGE TECHNICAL AND VOCATIONAL COLLEGE
DIPLOMA IN INFORMATION AND COMMUNICATION TECHNOLOGY
MODULE II
OBJECT ORIENTED PROGRAMMING
3 Hours
INSTRUCTIONS TO CANDIDATES
Answer ALL questions in answer booklet provided
All questions carry equal marks
Candidates should answer the questions in English
The paper consists of 3 printed pages
Candidates should check the question paper to ascertain that all the pages are printed as indicated
and that no question is missing
- 2. ©2023 Kendege Technical & Vocational College Page 2
1 a) Outline three typical steps in writing an object-oriented program (6marks)
b) Study the following C++ program and answer questions that follow
#include <iostream>
using namespace std;
class Room {
public:
double length;
double breadth;
double height;
double calculateArea() {
return length * breadth;
}
double calculateVolume() {
return length * breadth * height;
}
};
int main() {
Room room1;
room1.length = 42.5;
room1.breadth = 30.8;
room1.height = 19.2;
cout << "Area of Room = " << room1.calculateArea() << endl;
cout << "Volume of Room = " << room1.calculateVolume() << endl;
return 0;
}
Interpret the program segment clearly outlining the access specifiers used (6 marks)
c) Write out the output of the above program (4 marks)
d) Explain the terms state and behavior as used in object-oriented programming (4 marks)
2 a) With the aid of a C++ syntax code, explain an instance variable. (4 marks)
b) Mupyaro wrote a C++ program, the program failed to compile due to incorrect identifier
declarations. Explain three rules he should have followed (6 marks)
c) Explain three types of class access specifiers used in C++ programming (6 marks)
d) Distinguish between boolean and character literals as used in C++ programming (4 marks)
3 a) Write a C++ program to accept a string from the keyboard and store it in a file (8 marks)
b) With the aid of a syntax code, explain the use of break and continue statements (6 marks)
c) Describe namespace as used in a C++ program (2 marks)
d) Explain two types of exception in Object Oriented Programming (4 marks)
- 3. ©2023 Kendege Technical & Vocational College Page 3
4 a) Explain three error handling techniques used in C++ programming (6 marks)
b) State two differences between static and non-static data members as used in programming
(4 marks)
c) With the aid of syntax code, explain how member functions can be accessed using pointers
(6 marks)
d) Distinguish between encapsulation and abstraction as used in object-oriented programming
(4 marks)
5 a) With the aid of syntax code, explain inline functions (4 marks)
b) Write a C++ program that would initialize the values (20, 50, 40, 10, 30) into an array. The program
then displays the sum, maximum and minimum of the values (8 marks)
c) Outline four characteristics of constructors as used in Object Oriented Programming
(4 marks)
d) With the aid of a syntax code, explain copy constructor (4 marks)