Eit 4305 Advanced Object Oriented Programming
Eit 4305 Advanced Object Oriented Programming
SPECIAL/SUPPLEMENTARY EXAMINATION
SERIES: MAY/JUNE 2012
TIME: 2 HOURS
Instructions to Candidates:
You should have the following for this examination
- Answer Booklet
This paper consist of FOUR questions
Answer any THREE questions. Question ONE is compulsory
Maximum marks for each part of a question are as shown
This paper consists of THREE printed pages
e) Write a Java console application class to simulate a bank ATM cash point machine. The program
should display the following menu options to a user:
© 2012 – The Mombasa Polytechnic University College Page 1
ATM Menu
1) Withdraw Cash
2) Check Balance
3) Order Statement
4) Exit System
Please enter a number for a selection >>
When a user selects an option (1 – 3) the program should call an associated method that displays an
appropriate message showing that the method has been called correctly. After that the program
should then return to the menu and allow another selection to be made. All methods corresponding
to the menu options 1 – 3 should all be void. The program should terminate when option 4 is
selected. (13 marks)
Question Two (20 marks)
a) A constructor is a very special method in a class definition. Briefly explain what we mean by the
term constructor and give the distinguishing features that differentiate it from other member
methods.
b) (i) What is a default constructor? Explain and give the general syntax for defining a default
constructor.
c) How do we call the constructor of a parent class when defining the constructor of a child class?
Give the operator and hence its syntax of usage. (2 marks)
d) What does the term polymorphism mean? Explain. How can we achieve polymorphism in
inheritance? Explain (3 marks)
e) Briefly explain how accessibility of a member element in a parent class affects the inheritance of
the element in a child a class (6 marks)
Question Three
a) Briefly explain each of the following Java keywords:
i) Super
ii) Extends
iii) New (3 marks)
b) Define the term binding. Briefly distinguish static binding and dynamic binding. Which method
does Java use in binding its methods? Give. (4 marks)
c) A class called Vehicle is required. An object of the class vehicle will consist of the following
data attributes:
- A registration number of type string
- The make of the vehicle of type string
- The year of manufacture of type integer and
- The current value of the vehicle of type float
A constructor is required which will accept three arguments (parameters) to assign the first three
attributes. Then write two accessor methods that will be used to set and get the current value of
the vehicle. Then write three get accessor methods for other three data attributes. In addition a