29-4-21 SCS 202-Object Oriented Programming-1
29-4-21 SCS 202-Object Oriented Programming-1
DURATION: 2 HOURS
Instructions to candidates:
a) Discuss any THREE benefits of using user defined function in C ++. (3marks)
b)
i. List and explain two ways to add a comment to a C++ code. ( 4marks)
ii. Explain why we use comments in programs (2marks)
c) List any THREE advantages of object oriented programming over procedural
programming. (3marks)
d) Write a C++ program to print numbers from 1 to 5 using while loop. Write the expected
output of your program. (5marks)
e) List any FOUR rules for naming a variable in C++ (4marks)
f)
i. What is inheritance (1marks)
ii. Explain the importance of inheritance in object oriented programming. (2marks)
iii. Using a well labelled diagram, Explain:
a) Multi-level inheritance (2marks)
b) Multiple inheritance 2marks)
c) Hierarchical inheritance (2marks)
a) Consider a situation in which you have to add two integers’ numbers. Write a C++
program to solve this situation using.
i. Function with no argument and no return value. (4marks)
ii. Function with no argument but return a valve (4marks)
b) Compare and contrast C++ float and double data types with an example for each.
(4marks)
c) With a simple C++ program, explain the TWO ways to define functions that belong to a
class. (8marks)