DIT410  JAVA PROGRAMMING .

UNIVERSITY EXAMINATIONS: 2017/2018
EXAMINATION FOR DIPLOMA IN INFORMATION TECHNOLOGY
DIT410 JAVA PROGRAMMING
MODE: FULL TIME/PART TIME
ORDINARY EXAMINATIONS
DATE: JULY, 2018 TIME: 1 ½ HOURS
INSTRUCTIONS: Answer question ONE and any other TWO.

QUESTION ONE [20 MARKS]
a) Explain the difference between String, StringBuffer and StringBuilder.
6 Marks
b) Discuss four lexical elements in Java language
4 Marks
c) Briefly explain the following concepts associated with Java as a programming language:
i. Exception handling
ii. Multi-threaded
5 Marks
d) Discuss the steps involved in developing an object oriented system.
6 Marks
e) Differentiate between narrowing and widening casting in Java.
4 Marks
f) Write a java program to convert hours to minutes and vice versa depending on user needs.
5 Marks
QUESTION TWO [20 MARKS]
a) Explain the reasons for declaring variables in Java
4 Marks
b) Predict and explain the output of the following code:
public class prg {
public static void main(String[] args) {
int x=3;
System.out.println(++x)
System.out.println(–x);
}
}
4 Marks
c) Differentiate between static, instance and local variables.
6 Marks
d) Using examples, discuss the literal constants in java.
6 Marks
QUESTION THREE [20 MARKS]
a) Explain any four major differences between a class and an interface.
4 Marks
b) Discuss the process of exception handling in Java program
8 Marks
c) Suggest and explain the possible output of the java program below:
class ThreadEx extends Thread
{
public void run()
{
for(int i=1;i<=5;i++)
{
System.out.print(i);
}
}
public static void main(String args[])
{
ThreadEx T1=new ThreadEx();
ThreadEx T2=new ThreadEx();
T1.start();
T2.start();
}
}
8 Marks
QUESTION FOUR [20 MARKS]
a) Write a java program to store student marks and grades in two different arrays. Assume there
are 5 students. The grades shall be generated using the criteria below:


8 Marks
b) Describe the eight (8) basic data types used in a java program.
8 Marks
c) Explain the concept of variable initialization and its importance.
4 Marks
QUESTION FIVE [20 MARKS]
a) Using StringBuffer class, write a java program to read two strings then do the following.
Display the size of each string
Convert the two strings to uppercase
Reverse the characters in each string
Concatenate the strings
10 Marks
b) Predict and explain the output of the following code
public class temp
{
public static void main(String agrs[])
{
for(int i=1; i<=20; i+=2);
System.out.print(i);
}
}
6 Marks
c) Differentiate between continue and break statements in a loop.
4 Marks

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

Written by