BIT 2204 JAVA PROGRAMMING KCA Past Paper

UNIVERSITY EXAMINATIONS: 2014/2015
ORDINARY EXAMINATION FOR THE BACHELOR OF SCIENCE
IN INFORMATION TECHNOLOGY
BIT 2204 JAVA PROGRAMMING
DATE: APRIL, 2015 TIME: 2 HOURS
INSTRUCTIONS: Answer Question ONE and any other TWO

QUESTION ONE
a) Briefly explain the following versions of Java platform. [3 Marks]
i) Java 2 Micro Edition (J2ME).
ii) Java 2 Standard Edition (J2SE)
iii) Java 2 Enterprise Edition (J2EE
b) Write java code statements to accomplish the following. [5 marks]
i) declares two variables: ‘Max and Min
ii) Initializes the two variables with values 5 and 3 respectively
iii) Determines which value is larger among the two
iv) Prints results:
v) Declare and initialize array
c) Write a java program that compute the area of a rectangle and displays results.
[4 marks]
d) Explain the meaning of the following keywords. [2 marks]
i) java compiler
ii) Java interpreter [2 marks]
e) Write a java code statements that uses While loop to print the following ten numbers
[4 marks]
1234567910
f) Describe with examples the syntax of the following program flow controls and advice
when to use them. [4 marks]
i) do while
ii) For Loop
Write a well commented java program that requests the user to enter O-level results(e.g
Mean grade) and implement the following pseudo code to determine which course
programme the user can enroll for. [6 marks]
if grade is greater than or equal to C+
Print “ Qualified for to enroll for Bachelor degree”
else
if grade is greater than or equal to “C”
else
if student’s grade is greater than or equal to C-
Print “ Qualified for to enroll for Certificate ”
else
Print “Failed KCSE Exam. please Consider repeating
QUESTION TWO
a) Describe the meaning of the following terms. Draw a diagram that illustrates your
answer. [4 marks]
i) Array
ii) Array index
b) Briefly explain three characteristics of an array [3 Marks]
c). Write a program the reads and prints the contents of the following array [5 marks]


d) Write a Java program that Computes perimeter of a rectangle and prints results.
[4 marks]
e) Briefly explain the following java code [4 marks]
public class PROG
{ public static void main(String[] args)
{ Int x,y,results,diff;
x = 9;
y = 4;
sum = x + y;
diff = x – y;
System.out.println(“sum is ” + results);
System.out.println(“diff is ” + diff);
} }
QUESTION THREE
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) Syntax error:
d) 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]
e) Define what you understand by JVM and explain its importance in Java Programming
Is. [4 Marks]
e) Describe with explanation the structure of a Java program. [4 Marks
f) Write a well commented java program that prints the following output. [4 marks]
Age is 20
Name is peter
Course is Bscit
QUESTION FOUR
a) Define the meaning of the term ‘comment’. Explain three sections of a program where
comments can be used. [4 marks]
b) What is the purpose of the following keywords as used Java Programming? Give
examples to support your answer. [6 marks]
i) extends
ii) final
iii) encapsulation
d) Write a class named employee that instantiates a kcau_emp object from the class you
created. Prompt the a user to enter personal details such as idno, name, occupation and
then display all the values entered by the user. [6 marks]
d) Descrie the meaning of the term ‘constructor’. Write a sample java code that
implements a constructor. [4 marks]
QUESTION FIVE
a) Describe with examples the syntax of the following java programming terms
i) Package [2 marks]
ii) object [2 marks]
iii) Polymorphism [2 marks]
b) Consider the following java code instructions and explain the purpose of the single line
statements appearing in bold. [4 marks]
private static void createAndShowGUI()
{
JFrame frame = new JFrame(“Hi..”);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel(“Hello World”);
frame.getContentPane().add(label);
frame.pack();
frame.setVisible(true);
}
c) Briefly explain importance of using ‘LayoutManager’ when developing programs
using n swing with graphical interface. Write a sample java code utilizing
LayoutManager [4 marks]
d) Define the term ‘multiple inheritance’. Describe how multiple Inheritance can be
achieved in java programming language. Give the syntax used to implement concept.
[4 marks]
e) Describe the term interface as used in java programming language. [2 marks]

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

Written by