UNIVERSITY EXAMINATIONS: 2017/2018
ORDINARY EXAMINATION FOR THE DIPLOMA IN
DIT 410: JAVA PROGRAMMING
FULL TIME/PART TIME
DATE: MARCH, 2018 DURATION: 1 ½ HOURS
INSTRUCTIONS: Answer any THREE questions.
QUESTION ONE [20 MARKS]
a) Describe the four basic principles of object oriented programming.
b) Briefly explain the following concepts associated with Java as a programming language:
c) Write a java program to swap two values keyed in by the user. The two values must be stored in a
local variables x1 and x2.
d) Briefly describe the eight (8) primary data types in Java language.
e) Outline TWO disadvantages of arrays.
QUESTION TWO [20 MARKS]
a) Describe the general syntax of a java program.
b) Briefly describe static, instance and local variables.
c) Write a java program to read temperature in degrees Fahrenheit then convert to degree Celsius using
the formula: C=(F-32) *5/9, where C and F represent temperature in Celsius and Fahrenheit
d) Briefly explain the following classes is used in string reference types.
QUESTION THREE [20 MARKS]
a) In java programming, a method can be defined as a named group of statements that perform a specific
task in the program. In this regard, describe the syntax of a method in java.
b) Define the concept of class as used in java programming.
c) In a bank account management system, the details such as account number, account name, deposits
and withdrawal are to be captured by the system. Write a java program to use two class methodsgetAccountDetails () and Display (). The method getAccountDetails () will get values of account
number, account name, deposits and withdrawal through the keyboard for three customers. The
Display () method will calculate and display account number, account name, deposits, withdrawal and
balance for the three customers. Hint balance=deposit-withdrawal.
QUESTION FOUR [20 MARKS]
a) Write a java program to receive two string values then using StringBuilder class do the following:
Reverses characters in the first string
Insert characters “abc” in the first string
Concatenate thee two strings
b) In java programming, interface can be defined a collection of abstract methods. Explain three uses of
interface in java.
c) Write a java program to display the following input dialog:
QUESTION FIVE [20 MARKS]
a) Differentiate between method overloading and method overriding in java.
b) Describe two ways for overloading a method in java
c) Differentiate between checked and unchecked exceptions. Give an example for each.
d) Discuss the life cycle of a thread in java
e) Differentiate between continue and break statements in a loop.