0% found this document useful (0 votes)
16 views3 pages

29-4-21 SCS 202-Object Oriented Programming-1

Researched Lettter

Uploaded by

velma0483
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

29-4-21 SCS 202-Object Oriented Programming-1

Researched Lettter

Uploaded by

velma0483
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

MURANG’A UNIVERSITY OF TECHNOLOGY

SCHOOL OF COMPUTING AND INFORMATION


TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE

2020/2021 ACADEMIC YEAR


SECOND YEAR FIRST SEMESTER EXAMINATION FOR, BACHELOR OF
SCIENCE IN ELECTRICAL & ELECTRONICS ENGINEERING

UNIT CODE: SCS202

UNIT TITILE: OBJECT-ORIENTED PROGRAMMING

DURATION: 2 HOURS

Instructions to candidates:

1. Answer question One and Any Other Two questions.


2. Mobile phones are not allowed in the examination room.
3. You are not allowed to write on this examination question paper.
SECTION A: ANSWER ALL QUESTIONS IN THIS SECTION

QUESTION ONE (30 MARKS)

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)

SECTION B – ANSWER ANY TWO QUESTIONS IN THIS SECTION

QUESTION TWO (20 MARKS)

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)

QUESTION THREE (20 MARKS)

a) Explain encapsulation and its importance in object oriented programming. (4marks)


b) Distinguish between implicit and explicit type conversion in C++ 4marks)
c) Write a simple C++ program to check whether an integer is positive or negative using
If…Else statement. The program should consider zero (0) as a positive number. Write the
expected output of your program. (6marks)
d) Discuss any THREE access modifies/specifiers and their effect when implemented in
C++ classes. (6marks)
QUESTION FOUR (20 MARKS)
a) Write a simple C++ program to display a “hello world” text 5 times using FOR loop
statement. (6marks)
b)
i. Create a Car class with some attributes such as Model, Brand, and Year.
(4marks)
ii. From the car class above. Create a one object and print its attributes (4marks)
c)
i. What is a constructer in C++ (2marks)
ii. Create a constructor to display the message “Hello world” (4marks)

You might also like