0% found this document useful (0 votes)
0 views

Java past paper

The document outlines the examination details for a Java Programming course for the 2023/2024 academic year, including instructions for answering questions. It consists of several questions covering key concepts in Java such as classes, variables, loops, method overloading, and exception handling. Students are required to answer one compulsory question and two additional questions from a selection.

Uploaded by

joshuaonyango372
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Java past paper

The document outlines the examination details for a Java Programming course for the 2023/2024 academic year, including instructions for answering questions. It consists of several questions covering key concepts in Java such as classes, variables, loops, method overloading, and exception handling. Students are required to answer one compulsory question and two additional questions from a selection.

Uploaded by

joshuaonyango372
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

UNIVERSITY EXAMINATIONS: 2023/2024

EXAMINATION FOR DEGREE IN BACHELOR OF SCIENCE IN


INFORMATION TECHNOLOGY/ BUSINESS I.T/APPLIED COMPUTING/
SOFTWARE DEV./INFO. SECURITY& FORENSICS
BIT 2204A/ BBIT 310 /BAC 2201/ BSD 2107/BISF 2201:
JAVA PROGRAMMING
PART TIME/FULL TIME/DISTANCE LEARNING
ORDINARY EXAMINATION
DATE: DECEMBER, 2023 TIME: 2 HOURS
INSTRUCTIONS: Question One Is Compulsory, Choose Two Other Questions

QUESTION ONE (20 MARKS) COMPULSORY

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:
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 6 and 4 respectively
iii) Determines which value is larger among the two
iv) Prints results
v) Declare and initialize array
c) Give six characteristics of Java programming language? [6 marks]
d) Write a simple Java program to explain the working for do…while loop, write the expected
output of your program [3 Marks]
e) With a well written Java Program explain the difference between method overloading and
method overriding [6Marks]
f) Briefly explain the following java code [4 marks]
public class Compute {
public static void main(String[] args) {
int a,b,results,diff;
a = 10;
b = 5;
sum = a + b;
diff = a – b;
System.out.println(“sum is " + results);
System.out.println(“diff is " + diff);
}}

QUESTION TWO (15 MARKS)


a) Define what you understand by JVM and explain its importance in Java Programming
[3 Marks]
b) Using one statement for each and some explanation, illustrate how the following string
functions are implemented [6 Marks]
i) Substring
ii) indexOf
iii) concat
c) Write a well commented java program that prints the following output. [6 marks]
i) Name is James
ii) Age is 30
iii) Course is BAC

QUESTION THREE (15 MARKS)


a) Explain the importance of interface as applied in java programming [3 Marks]
b) What is the purpose of the following keywords as used Java Programming? Give examples
to support your answer. [6 Marks]
i) try
ii) exception
iii) throws
c) Write a class named staff that instantiates a kcau_staff object from the class you created.
Prompt the user to enter personal details such as id no, name, age and then display all the
values entered by the user [6 Marks]
QUESTION FOUR (15 MARKS)
a) What is the relevance of the following keywords? [6 Marks]
i) this
ii) .Instanceof
iii) extends
b) Convert the following Pseudocode to java switch structure [5 Marks]
if student’s grade is greater than or equal to 70
Print “A”
else
if student’s grade is greater than or equal to 60
Print “B”
else
if student’s grade is greater than or equal to 50
Print “C”
else
if student’s grade is greater than or equal to 40
Print “D”
else
Print “F”
c) Differentiate between the following
i). Superclass and Subclass [2 Marks]
ii). Single inheritance and Multilevel inheritance [2 Marks]

You might also like