DCS 013 - Object Oriented Programming Examinations
DCS 013 - Object Oriented Programming Examinations
GENERAL INSTRUCTIONS:
Students are NOT permitted to write on the examination paper during reading time.
This is a closed book examination. Text book/Reference books/notes are not
permitted.
SPECIAL INSTRUCTIONS:
This examination paper consists Questions in Section A followed by section B.
Answer Question 1 and any Other Two questions.
QUESTIONS in ALL Sections should be answered in answer booklet(s).
SECTION A (COMPULSORY)
Page 1 of 5
QUESTION 1 (30 Marks)
A. Define the following terms. ( 4 Marks)
i. Encapsulation
ii. Inheritance
iii. Polymorphism
iv. Constructor
B. Write a program in C++ that asks user to input from 5 to 9 then calculate the average.
(5 Marks)
C. Explain what ARRAY is. (2 Marks)
D. Illustrate what an object is. ( 2 Marks)
E. With examples, give two applications of Object Oriented Programming. (4 Marks)
F. Define an array of 10 doubles and show their index positions. (2 Marks)
G. When do we use “=” and “==” signs in C++? ( 2 Marks)
H. Distinguish between a warning from the compiler and an error message from the
compiler? ( 2 Marks)
I. What is a reference in C++? Give an example. ( 2 Marks)
J. Can you declare a variable, and at the same time assign a value to it? Give an example.
(2 Marks)
D. Can I have multiple main methods in the same class in Java? Reason? ( 2 Marks)
E. What is the purpose of having comments in source files during object-oriented
programming? Using an example show how comments are declared ( 3 Marks)
int main () {
// local variable declaration:
char grade = 'D';
switch(grade) {
case 'A' : cout << "Excellent!" << endl;
break;
case 'B' : case 'C' : cout << "Well done" << endl;
break;
case 'D' : cout << "You passed" << endl;
break;
Page 2 of 5
case 'F' : cout << "Better try again" << endl;
break;
default : cout << "Invalid grade" << endl;
}
cout << "Your grade is " << grade << endl;
return 0;
}
G. Describe the three basic logical operators with their symbols and how they are
represented in C++ programs. ( 3 Marks)
int main ()
{
char campus[6] = {'R', 'I', 'A', 'R', 'A', '\0'};
cout << "Best University is: ";
cout << campus << endl;
return 0;
}
Page 4 of 5
I. Why do we include break statement in the switch case programs? ( 1 Mark)
Page 5 of 5