Ics 2104-Object Oriented Programming 1
Ics 2104-Object Oriented Programming 1
Ics 2104-Object Oriented Programming 1
SPECIAL/SUPPLIMENTARY EXAMINATIONS
OCTOBER 2023
DURATION: 2 HOURS
TIME:
INSTRUCTIONS TO CANDIDATES
1. This examination paper has FIVE (5) questions.
2. Candidates are required to attempt Question 1 and ANY OTHER TWO questions.
3. No reference material OF ANY KIND should be carried into the examination room.
e) Discuss the following object-oriented concept; use a sample code example in each case
i. Inheritance (4 marks)
ii. Polymorphism (4 marks)
Question 2
a) Describe any four types of inheritance used in Object oriented programming [8 marks]
b) Define the class Person which has name (char*) and age (int). Define the following constructors a. default b. with
name as argument (assume age is 18) c. with name and age as argument Also define the copy constructor [8 marks]
c) What is function overloading? Use sample code to explain this concept [4Marks]
Question 3
a) Device an object-oriented program that uses an array to store four names and display the names. (8 marks)
b) Define a multidimensional array and illustrate how to declare and how to access element in that array? (4 marks)
c) Describe a constructor and devise an object-oriented program that demonstrates the use of constructor (4 marks)
d) How do the properties of following two derived classes differ? [4 Marks]
(i) class X : public A{//..}
(ii) (ii) class Y : private A{//..}
Question 4
a) Encapsulation is an important concept in object-oriented programming; device a syntax that depicts the use of this
concept. (4 marks)
b) Discuss exception and explain the significance of exception handling in a program (4 marks)
c) What is multiple inheritance? Discuss the syntax and rules of multiple inheritance in Java. How can you pass
parameters to the constructors of base classes in multiple inheritance? Explain with suitable example [12 Marks]
Question 5
a) Devise an object-oriented sample program that illustrates the concept of overloading a function. [6 marks]
c) Create a class “Mycircle” that uses two member functions “area” and “circumference” to calculate and print the area
and the circumference of a circle plus an additional function “input” to capture the required input from a user.
[5 marks]
d) Differentiate between Local and global variables using a snippet code example in class declaration [3 marks]
e) The diagram shows an example of an inheritance hierarchy for different types of bank account s Using a syntax code
demonstrate how to create these subclasses using appropriate inheritance code [6 marks]
ACCOUNT
FIXED
SAVINGS CURRENT
DEPOSIT