DIT 077 OBJECT ORIENTED PROGRAMMING
DIT 077 OBJECT ORIENTED PROGRAMMING
QUESTION ONE (24 MARKS)
a)
Define
the following terms as used in object oriented programming
i.
Inheritance (2 marks)
ii.
Abstraction (2 marks)
iii.
Encapsulation (2 marks)
iv.
Polymorphism (2 marks)
v.
Constructor (2 marks)
vi.
Object (2 marks)
b)
i.
Differentiate
between method overloading and method overriding as applied in java programming. (4 marks)
ii.
State any
four applications of java programming language (4 marks)
iii.
Differentiate
default and parameterized constructors (4 marks)
QUESTION TWO (18 MARKS)
a)
State four differences between a java method
and a java constructor. (4 marks)
b)
Using diagrams,
explain any three types of inheritance. (6 marks)
c)
Write a
complete java application to prompt the user for the radius of a sphere, and
call method sphereVolume to calculate and display the volume of the sphere. Use
the following statement to calculate volume: (4.0/3.0) * Math.PI * Math.pow(radius,
3) (8 marks)
QUESTION THREE (18 MARKS)
a)
i.
State the
four access specifiers used in java programs (4 marks)
ii.
Using a for
loop write a java program to output number 1 to 20 (6
marks)
b)
Write a
java program snippet that implements java method overloading. (8
marks)
QUESTION FOUR (18 MARKS)
a)
Outline four
areas that distinguishes an inheritance from a java class (4 marks)
b)
Distinguish
between aggregation “has-a” and Generalization “is-a” relationship using well labeled
diagrams. (6 marks)
c)
Write a
java program that calculates the area of a circle using a java method. (8
marks)
QUESTION FIVE (18 MARKS)
a)
Give any
four features of object oriented languages. (4
marks)
b)
Differentiate
between a formal and actual parameter
(4 marks)
c)
Write a
java program that implements inheritance to calculate the area of triangle and
rectangle as shown in the diagram below. (10
marks)
Comments
Post a Comment