DIT 409 – JAVA PROGRAMMING KCA Past Paper

UNIVERSITY EXAMINATIONS: 2021/2022
EXAMINATION FOR THE DIPLOMA IN INFORMATION TECHNOLOGY
DIT 409: JAVA PROGRAMMING
FULLTIME/ PART TIME
DATE: NOVEMBER, 2021 TIME: 2 HOURS
INSTRUCTIONS: QUESTION ONE IS COMPULSORY, CHOOSE TWO OTHER
QUESTIONS

QUESTION ONE (20 Marks) Compulsory
a) Write java code statements to accomplish the following. [5 Marks]
i) declares following variables: ‘Max and Min
ii) Initializes the two variables above with values 5 and 3 respectively
iii) Determines largest variable amongst the two above
iv) Prints results of the largest variable:
v) Declare and initialize array
b) Write a java program that compute the area of a rectangle and displays results.
[4 Marks]
c) State and explain four features of java programming language (4 Marks)
d) Write a Java program that determines a student’s grade. The program will read three types of
scores(quiz, mid-term, and final scores) and determine the grade based on the following rules: -if the
average score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if the
average score>=50% and <70% =>grade=C -if the average score<50% =>grade=F
(7 Marks)
QUESTION TW0 (15 Marks)
a) Briefly explain the meaning of the following terms as used in java programming. Give java
code example for each case. [6 Marks]
i) Class
ii) Variable
iii) Inheritance
b) Computer programs are very closely tied to the specific hardware and operating system they
run. A Windows program will not run on a computer that only runs DOS. A Mac application
can’t run on a UNIX workstation. VMS code can’t be executed on an IBM mainframe, and
so on. How does java resolve this platform problem? [2 Marks]
c) Define what you understand by JVM and explain its importance in Java Programming
[3 Marks]
d) Write a java class that reads and prints the values of the following array. [4 Marks]


QESTION THREE (15 Marks)
a) Briefly explain the meaning of the following terms in the context of java programming.
Write java code snippet that demonstrates implementation of each case. [4 Marks]
i). one dimension Array
ii) Two-dimension array
b) Briefly explain the following java code including its output [5 Marks]
switch (day)
{
case 1:
System.out.println (“sunday ” );
break;
case 2:
System.out.println (“Tuesday ” );
break;
case 3:
System.out.println (“Wednesday ” );
break;
default : System.out.println (“unknown ” );
break;
}
c) Describe the key word ‘import’ as used in java. Write a single line java code illustrating
how ‘import’ can be used in java programming (2 Marks)
d) Explain the meaning of the following keywords
i. constructor (2 Marks)
ii. static method (2 Marks)
QUESTION FOUR (15 Marks)
a) Describe the term ‘exception ‘ as used in java programming language [2 Marks]
b) Describe two types of exceptions in the context of java programming [4 Marks]
c) Distinguish between method over ridding and method overloading as used in objected
oriented programming languages such as java. Give an example java code implementing
for each case (6 Marks)
d) Describe the term ‘polymorphism’ as used in java programming language (3 Marks)

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

Written by