DIT410  JAVA PROGRAMMING 2.

UNIVERSITY EXAMINATIONS: 2018/2019
EXAMINATION FOR DIPLOMA IN INFORMATION TECHNOLOGY
DIT 410: JAVA PROGRAMMING
MODE: FULL TIME/PART TIME
ORDINARY EXAMINATIONS
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.
4 Marks
b) Explain the FIVE states of a thread in Java programming.
5 Marks
c) Describe the following terms.
i. Byte code
ii. Interface
iii. Package.
iv. Class
v. Method
5 Marks
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.
4 Marks
e) Write a Java program to read six characters, store then in an array, sort then display in
descending order.
8 Marks
f) For each of these expressions, determine its result. Assume the value of text is a string
“Java Programming”
String text = “Java Programming”;
i. text.substring(0,4)
ii. text.length()
iii. text.substring(8,12)
iv. text.substring(0,1) + text.substring(7,9)
4 Marks
QUESTION TWO[20 MARKS]
a) What is an exception as used in Java programming?
2 Marks
b) What is the difference between checked and unchecked exceptions?
4 Marks
c) Briefly explain String Buffer as used in Java programming.
2 Marks
d) Briefly outline any three methods used in String Buffer class.
6 Marks
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
9102.
6 Marks
QUESTION THREE [20 MARKS]
a) Define a wrapper class as used in java langauge.
3 Marks
b) Complete the following table of primitive types using the corresponding wrapper class for
each type.


5 Marks.
c) Explain the concept of method overloading as used in java programming.
4 Marks
d) Write a java program to demonstrate the use of method overloading
8 Marks
QUESTION FOUR [20 MARKS]
a) Differentiate between a local variable and instance variable in java.
2 Marks
b) Write a Java program to calculate the area and circumference of a circle, given the following

8 Marks
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.
6 Marks
d) Write a java program to print integers that are multiples of five between 2 and 61.
4 Marks
QUESTION FIVE [20 MARKS]
a) Differentiate between order of precedence and associativity as used in java operators.
2 Marks
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.
9 Marks
c) Describe the steps involved in handling exceptions in Java.
4 Marks
d) Using an example describe constructor method as used in Java programming.
5 Marks

(Visited 157 times, 1 visits today)
Share this:

Written by