Java past paper
Java past paper
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);
}}