0% found this document useful (0 votes)
149 views4 pages

Object Oriented Programing0001

This document is an examination paper for Object Oriented Programming from the Kenya National Examinations Council, intended for candidates in the Diploma in Information Communication Technology. It contains instructions for answering questions, a variety of programming tasks in C++, and theoretical questions related to OOP concepts such as encapsulation, data hiding, and class implementation. Candidates are required to answer five out of eight questions, covering topics like constructors, operator overloading, and file handling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
149 views4 pages

Object Oriented Programing0001

This document is an examination paper for Object Oriented Programming from the Kenya National Examinations Council, intended for candidates in the Diploma in Information Communication Technology. It contains instructions for answering questions, a variety of programming tasks in C++, and theoretical questions related to OOP concepts such as encapsulation, data hiding, and class implementation. Candidates are required to answer five out of eight questions, covering topics like constructors, operator overloading, and file handling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
2920/203 OBJECT ORIENTED PROGRAMMING June/July 2023 Time: 3 hours THE KENYA NATIONAL EXAMINATIONS COUNCIL DIPLOMA IN INFORMATION COMMUNICATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING 3 hours INSTRUCTIONS TO CANDIDATES Answer FIVE of the following EIGHT questions in the answer booklet provided. All 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. (©2023 The Kenya National Examinations Council Turn over (b) © @ ) © (b) © 2920/203 June/July 2023, (Explain how data hiding is achieved in OOP. (2 marks) (ii) Differentiate between procedure-oriented programming and object-oriented programming (4 marks) Outline four advantages of OOP over unstructured programming. (4 marks) Ivana intends use OOP to develop her trade project. Explain two technical challenges associated with this programming paradigm she is likely to encounter. (4 marks) Write a C++ program that implements a class named Circle with the following, properties: . has diameter as a data member; = amember function named calculate for inputting the diameter, determining the area and outputting the area of a circle. (6 marks) Outline three examples of unary operators used in C++ programs. (3 marks) Distinguish between class declaration and class implementation as used in oor. (4 marks) () Explain the following terms as used in OOP: 1. accessor function; (2 marks) I. mutator function. (2 marks) (ii) Differentiate between extern and static global variables as used in OOP. (3 marks) Write a C+ program to implement a class named Savings containing three floating- point data members named balance, rate, and interest and a constructor that initializes each data member to 0. Include a member function that inputs a balance and rate and then calculates and outputs the simple interest. (6 marks) Explain the term encapsulation as used in OOP. (2 marks) (i) Describe two situations where inline functions are NOT applicable in OOP. (4 marks) (ii) Junior is designing a module of an object-oriented application that requires passing an object as an argument to a function. Explain three ways he could consider to meet this req (6 marks) Write a C+ program that implements an array of five objects for a class with following, features: + one integer data member, = _amember function to set the data member to the index value of a finite loop; + member function to determine the square of the set data member. ‘The program should output accordingly. (8 marks) 2 4 @) (b) (©) (b) © (@) 6 (a) (>) (©) 2920/203 June/July 2023 (Outline two functions of comments in object-oriented programs. (2 marks) (i) Explain two typical characteristics of friend functions. (4 marks) (@ With the aid of a general syntax, explain the function of a copy constructor. (G marks) (i) Distinguish between private and public members of a class. (4 marks) Write a C+ program that will use a constructor to initialize two objects of a class named Triangle as follows: triangle 1 B=4, H-3 and Hy-5; triangle 2 B=7, H=9 and Hy=12. ‘The program should then use a friend function to determine the perimeter and output appropriately. (7 marks) Outline four reasons why function overloadi portant in OOP. (4 marks) Distinguish between default and parameterized constructors as used in OOP. (4 marks) Describe two features of destructors as used in OOP. (4 marks) ‘The CAT and Exam marks of student! and student 2 were recorded as student] (14, 40) and student? (23, 60). Write a C+ program that could be used to initialize two objects, with the respective CAT and Exam marks, and use operator overloading to determine the difference between the CAT marks and Exam marks respectively. The program should output the values of the respective differences. (8 marks) (Outline two types of streams associated with files in OOP. (2 marks) Explain two uses of files in application development. (4 marks) Ann intends to use OOP for her trade project in Module III. Explain two ways she could employ to cope with the likely emerging trends in OOP. (4 marks) Write a C+ program that will carry out the following: * declares a class named Circular that has data members radius and height, and a member function named ser_dim which is used to initialize the radius and height; + implements a polymorphic function named volume which determines the volume of a cylinder and a cone in sub-classes named Cylinder and Cone respectively; * outputs the volume of a cylinder and a cone with radius and height as 28 cm and 10cm respectively. (10 marks) 3 Turn over () © () (©) @) 2920/203 June/July 2023 (i) Outline two OOP concepts facilitated by overriding. (2 marks) (ii) Operator overloading is effective when implemented within some guidelines. Outline four rules that should be observed when using it in OOP. (4 marks) Explain two roles of destructors in OOP. (4 marks) Figure | depicts the relationship among some classes (class name is bolded). Study and use it to answer the question that follows. Numadd| Members: num1, num2, getdata() Minus + Plus| Members: sum, Members add() nl,n2, diff, subtract() Member: + display) [* Figure 1 Result Write a C++ program that would implement the form of inheritance depicted in the Figure 1. (10 marks) Describe an operator used for object memory allocation and another used for memory deallocation in C++. (4 marks) Distingt between static and dynamic binding as used in OOP. (4 marks) Write a C+ program that will type the following information to a file. OP is interesting Let us try it ‘The program should check whether the file is open before typing the information. (6 marks) ‘An abstract base class is key in OOP. With the aid of a C++ program segment, explain the function of abstract base classes as used in OOP. (6 marks) THIS IS THE LAST PRINTED PAGE.

You might also like