0% found this document useful (0 votes)
24 views3 pages

Eit 4305 Advanced Object Oriented Programming

Uploaded by

Alex Miano
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
24 views3 pages

Eit 4305 Advanced Object Oriented Programming

Uploaded by

Alex Miano
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 3

THE MOMBASA POLYTECHNIC UNIVERSITY COLLEGE

(A Constituent College of JKUAT)

Faculty of Engineering & Technology

DEPARTMENT OF COMPUTER SCIENCE & INFORMATION TECHNOLOGY

UNIVERSITY EXAMINATION FOR BACHELOR OF TECHNOLOGY IN INFORMATION


COMMUNICATION TECHNOLOGY (BTIT/MAY2011/S-EV)

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

Question One (Compulsory – 30 marks)


a) Define the term layout manager and briefly explain the how each of the following layout
managers arrange CUI components:
i) FlowLayout
ii) BorderLayout
iii) BoxLayout (4
marks)

b) (i) What does the acronym API stand for? Give


(ii) In which Java API are all standard stream objects defined? Give
(iii) In which Java API is the JFrance class defined? Give (4 marks)

c) (i) What is wrapper class? Explain


(ii) Using the wrapper class Double write a method that reads and returns a float value. Assume
you are writing this method in an application class (5 marks)

d) With the aid of an example distinguish between the following:


i) An overloaded and overridden method
ii) Class method and an instance method (4 marks)

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.

(ii) How is a default constructor different from a parameterized constructor? Explain.


(4 marks)

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

© 2012 – The Mombasa Polytechnic University College Page 2


method (call it VehAge) is needed which accepts as an argument a year and returns the age of the
vehicle.
Write a child class of Vehicle called SecondHandVehicle, this has an additional attribute,
numberOwners, which needs to be initialized at the time of creation and read acess is also
required. An additional method (call is repOwners) is required which returns as a string a
message telling us whether the vehicle has had more than one previous owner. (13 marks)
Question Four
Create a problem domain class called ‘Person’ that contains the following instance variables:
- Surname of the type string
- Othernames of the type string
- Age of the type integer
- Marital_status of the type string
- Gender of the Boolean
The instance variable marital status can take three values namely: Single, married and Divorced. The
instance variable marital_status is of the type Boolean and hence can take the values true or false, in
our case these two values will represent the gender of the person either female or male, hence true
will represent female and false will represent male.
The class will also include two parameterized constructors as follows:
- The first constructor should accept five parameter values, each corresponding to the nnamed
instance variable above. Each parameter value should be used to initialize its corresponding
instance variable in the class.
- The second constructor should accept four parameter values corresponding to the surname,
othernames, age and gender instance variables. Each parameter value should be used to
initialize its corresponding instance variable in the class. In this constructor the instance
variable marital_status should be assigned the value Single. For each instance variable, the
class should define a set and get accessor method, hence you should define ten(10) accessor
methods in this class.
Then you should also define a custom method called getMaarried that will accept one string
parameter value. The method will be of the return type void and should change the marital_status of
a person object to Married and check if the gender of the person getting married is Female, then
change the surname instance variable of that person object to the string parameter value passed.
Using the problem domain class written above, write an application class that will create two objects
called Thomas and Mary using the second constructor for both, the tom object is a male object while
the Mary object is female object. Then program should display the details of each person object.
Using the object Mary call the method getMarried and pass the surname of the object Thomas, then
after that display the details of the person object Mary. (20 marks)

© 2012 – The Mombasa Polytechnic University College Page 3

You might also like