Ics 2104 Eit 4108 Object Oriented Programming Fundamentals of Object Oriented Programming (1)
Ics 2104 Eit 4108 Object Oriented Programming Fundamentals of Object Oriented Programming (1)
d) Write a segment of code that gets the sum of all numbers between 100 and 300 that are divisible by
5 using the:
(i) Do…..while loop (5 marks)
(ii) For…..Loop (4 marks)
Question Two
With the use of Java code fragments, implement the following features of object-oriented paradigm:
(i) Inheritance (5 marks)
(ii) Polymorphism (5 marks)
(iii) A class to hold student details and calculate student marks. (5 marks)
(iv) A statement to instantiate TWO objects of the class defined in Question 2 (iii) above and
initiate them with appropriate values. (5 marks)
Question Three
a) Using appropriate examples, describe the THREE control structure in Java programming
Language. (9 marks)
b) There are TWO major types of Java Programs. List the TWO types and explain how they differ
from one another. (6 marks)
c) Explain the main differences between the do…while statement and the while….statement.
(5 marks)
Question Four
Write a program that uses a class employee to display an employee’s information. The class should
include the following members:
Data numbers (Employee number, Employee name, basic salary, house allowance, medical allowance,
income tax)
Member functions (to read values, to calculate gross salary, to display values) (20 marks)
Question Five
a) Define the following:
(i) Constructor (3 marks)
(ii) Method (3 marks)
b) Write a program that uses a class named circle to accept the radius of a circle and compute both the
area and circumference (area = pi* radius* radius, circumference = Pi* diameter)
(14 marks)