0% found this document useful (0 votes)
20 views

2017july (3)

The document is an examination paper for the Diploma in Information Technology focusing on Object Oriented Programming, issued by the Kenya National Examinations Council. It consists of eight questions, from which candidates must answer any five, covering topics such as abstract data types, C++ programming, classes, inheritance, and polymorphism. The paper includes instructions for candidates and outlines various programming tasks and theoretical questions related to OOP principles.

Uploaded by

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

2017july (3)

The document is an examination paper for the Diploma in Information Technology focusing on Object Oriented Programming, issued by the Kenya National Examinations Council. It consists of eight questions, from which candidates must answer any five, covering topics such as abstract data types, C++ programming, classes, inheritance, and polymorphism. The paper includes instructions for candidates and outlines various programming tasks and theoretical questions related to OOP principles.

Uploaded by

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

2921203

OBJECT OREENTED PROGRAMMING


July 2017

Time: 3 hours

THE KENYA NATIONAL EXAMINATIONS COUNCIL

DIPLOMA IN INFORMATION TECHNOLOGY

MODULE Il
OBJECT ORIENTED PROGRAMMING

3 hours

INSTRUCTIONS TO CANDIDATES

You showld have an answer booklet for this examination:


This paper consists of EIGHT questions.

Answer any FIVE in the answer booklet provided.

Alf questions carry equal marks.

Candidates should answer the questions in English.

This paper consists of 4 printed pages.

Candidates should check the question paper to ascertain that all the
pages are printed as indicated and that no questions are missing.

{ 2017 The Kenya National Examinations Council.

Turn over
(b)

(c)

(d)

(b)

(c)

{d)

{b)

4.) (a)

2920/2033
July 2047

(i) Outline four characteristics of abstract data types (ADTs). (4 marks)


(ii) Explain the term message as used in OOP. (2 marks)

With the aid of a C++ example in cach casy, differentiate between a variable and a
constant. {4 marks)

Describe two circumstances under which the de. wife doop is most applicable im OOP.
, (4 marks)

Write a C++ program that implements a class named siyclass with the [ollowing
features: (6 marks}
Data members @ and b;
A member function named set/ to assign characters “O" and *P* to ¢ and A
respectively, and ou(puts a concatenation of e and &.

Lxplain the purpose of using the namespace std in C++ programs. (2 marks)
00) Distinguish between struct and clays data structures as used in Ci +. (4 marks)

Gi) Quiline four categories of operators used in C+ giving an exampte in each


case. | {4 marks)
Draw a program flowchart to show the execution logic ofa while loop structure,
(4 marks)

Writc a C++ program that would implement a class with the dimensions of a cylinder
as
data members. The program should then accept the dimensions, determine and display
the volume of the cylinder using a friend function, (6 marks)

Outline four typical features of object oriented programming that makes it popular
in
application development. (4 marks)
(i) Explain two aims of object oriented analysis and design (QOD). (4 marks)

(il} Differentiate between accessor operation and setter operation as used in OOP.
(4 marks}

Design two classes with relevant data and methods thal can be used to manage the
following communication model in a college. (8 marks)

The Whatsup group directory of a college contains entries for cach person in the
college
icc. student, tutor, and staff member. Users of the directory can look up names,
set
phone number and chat. However, the administrator of the directory can, after
supplying
a password, insert new cntries, delete existing entries, modify existing entries,
print the
iclephone directory, and print a listing of all students or of all members of
staff,

Explain the following terms as used in OOP:


{i) instantiation: , (2 marks)

(11) access specifier. (2 marks}


(b) Deseribe the circumstance under which cach of the follawing C++ program
elements
are most applicable:

ay Scape resolution operator: (2 marks)


(it} = Object parameter. (2 marks)
(} Write a C++ program segment to demonstrate the use of (Ais pointer in a
comsiructor.

(4 marks}
{d) {i) Outline une advantage and one disadvantage of using overloaded functions in
OOP. . (2 marks)
(i) Write a C++ program that will accept the dimensions of a cuboid and use an
overloaded function called calculate to determine the cross-sectional area or

volume of the cuboid. Display the area and volume accordingly. (6 marks)
5 (aj Outline four rules of setting destructors in GOP. {4 marks)
(b) (i) Explain two ways in which copy constructors are used in C++ programs.
(4 marks)
(i) Distinguish between text file and data file as applied in C-+++ programs.
(4 marks)
{c) Write a C++ program that will initialize two objects, ObL (7, 8) and Ob2 (2,
5), using a
constructor. The program should then determine the difference of the objects usmg
an
overloaded operator and display ihe values of resultant object. (8 marks)
6. (a) (i) List four operators that cannot be overloaded. (2 marks)
(it) Outline two restrictions that must be considered when overloading operators in
OOP. {2 marks}
{b) (i) Explain two benefits of using tiles in OO programs. {4 marks)
(i) Distinguish between a stream and a template class with respect ta C++ fies.
{4 marks}
{c) Evaluate the folowing C++ statement clearly showing your working.
OF 3-32 /1S% 77-2612 1 5*2-9/3
(2 marks)
{d) Figure 1 shows the relationship between two classes. Write a C++ program to
implement the relationship and output a. b and sum of all the data members. (6
marks)
Data: a
Methods: set a to 100;
| Derives
Data: b
Methods: set b to 237;
Figure 1
2921203 3 Turn over

duly 2077
(b)

(c)

8. fa)

(b)

{c)

2920/203

July 2017

(i) Explain the following terms as in inheritance:


1. override; (2 marks)
II. variance. (2 marks)
(ii} Describe the circumstance under which a virtual base class is applicable in
GOP.
(2 marks)
(i) Files can be implemented using different open modes based on their purpose.
Assuming C++ programming language, outline four values of the openmedes.
4 marks)
(ii) = Write a C++ program segment that would open a marks database file
for reading, after verifying that it is open, and outputs the contents to the
screen.
Note that the file contains examination marks only. (4 marks)
With the aid of an example in each case, explain three types of polymorphism
applicable in OOP. (6 marks)
(i) Write the C++ general syntax for a polymorphic class. (3 marks)
{il} Differentiate between abstract base class and normal base class as used in
OOP.
{4 marks)
(1) Sharing is the basic idea of inheritance. Justify this statement with respect
to
OOP. (3 marks)
{ii} A student intends to solve a programing problem using a constructor and a

destructor in both the base and derived classes. With the aid of a C++ program

segment, demonstrate the process of creating and deleting the respective objects.

{6 marks)

A software development company has adopted OOP in its current projects. Explain
two ways in which the company would use to cope with the emerging trends in OOP,

(4 marks)

THIS IS THE LAST PRINTED PAGE.

You might also like