UNIVERSITY EXAMINATIONS: 2018/2019
EXAMINATION FOR DIPLOMA IN INFORMATION TECHNOLOGY
DIT 410: JAVA PROGRAMMING
MODE: FULL TIME/PART TIME
DATE: MARCH, 2019 TIME: 2 HOURS
INSTRUCTIONS: Answer question ONE and any other TWO.
QUESTION ONE[30 MARKS]
a) Give FOUR advantages of Java as an object oriented programming language.
b) Explain the FIVE states of a thread in Java programming.
c) Describe the following terms.
i. Byte code
d) Java has both primitive and reference types. Name an appropriate primitive data type to
represent each of the follow:
i. The number of students in a university
ii. The average age of a student in the university
iii. Whether or not a student has enrolled
iv. The response of the asked to type ‘y’ to continue or ‘n’ to exit.
e) Write a Java program to read six characters, store then in an array, sort then display in
f) For each of these expressions, determine its result. Assume the value of text is a string
String text = “Java Programming”;
iv. text.substring(0,1) + text.substring(7,9)
QUESTION TWO[20 MARKS]
a) What is an exception as used in Java programming?
b) What is the difference between checked and unchecked exceptions?
c) Briefly explain String Buffer as used in Java programming.
d) Briefly outline any three methods used in String Buffer class.
e) Write a java program to read a non-zero integer then reverse its digits then display the
resultant number e.g. if the user keys in 2019 the program will reverse the digits and display
QUESTION THREE [20 MARKS]
a) Define a wrapper class as used in java langauge.
b) Complete the following table of primitive types using the corresponding wrapper class for
c) Explain the concept of method overloading as used in java programming.
d) Write a java program to demonstrate the use of method overloading
QUESTION FOUR [20 MARKS]
a) Differentiate between a local variable and instance variable in java.
b) Write a Java program to calculate the area and circumference of a circle, given the following
c) In java language, a statement can be defined as a complete instruction to a computer to
perform some task. In this regard, describe the following types of java statements.
i. Empty statement.
ii. Selection statetement.
iii. Jump statement.
d) Write a java program to print integers that are multiples of five between 2 and 61.
QUESTION FIVE [20 MARKS]
a) Differentiate between order of precedence and associativity as used in java operators.
b) The table below shows the water billing criteria in a certain town. Use it to answer the
question that follows.
Write a java program that accepts the current and previous meter readings, the program then
computes and outputs amount pyable by client. Note that a standing charge of Ksh.120 is
chargeable for all customers regardless of the units used.
c) Describe the steps involved in handling exceptions in Java.
d) Using an example describe constructor method as used in Java programming.