INSTRUCTIONS: Answer Question One and Any other Two Questions

Question One
a) Discuss the following elements of OOP [8 Marks]
i). Encapsulation
ii). Information Hiding
b) Give SIX characteristics of Object Oriented programming language? [6 Marks]
c) A public method named computeSum() is located in classA. Write a statement that would
call the method from within classB. [2 Marks]
d) What will the following program output [3 Marks]
class SetUpSite2
public static void statementOfPhilosophy()
System.out.println(“Event Handlers Incorporated is”);
System.out.println(“dedicated to making your event”);
System.out.println(“a most memorable one.”);
public class TestStatement2
public static void main(String[] args)
(“Calling method from another class:”);
e) What is the difference between a break statement and a continue statement? [2 Marks]
f) Create a class named Eggs. Its main() method holds an integer variable named
numberOfEggs to which you will assign a value. Create a method to which you pass
numberOfEggs. The method displays the eggs in dozens; for example, 50 eggs is 4 full dozen
(with 2 eggs remaining). [6 Marks]
g) What is package in JAVA?
[1 Mark]
Question Two
a) Explain the difference between static and non-static member of a class. [2 Marks]
b) Define inner class in Java [2 Marks]
c) What is the relevance of the following keywords? [6 Marks]
i). this
ii). instanceof
d) Create a class named Monogram. Its main() method holds three character variables that hold
your first, middle, and last initials, respectively. Create a method to which you pass the three
initials and which displays the initials twice—once in the order first, middle, last, and a second
time in traditional monogram style (first, last, middle). [6 Marks]
e) When does a name clash occur? [2 Marks]
f) Briefly state the difference between static and dynamic modeling [2 Marks]
Question Three
a) Define serialization as applied to Java Programming Language [2 Marks]
b) What are synchronized methods and synchronized statements? [6 Marks]
c) Differentiate between the following [6 Marks]
i). superclass and subclass
ii). overloading and overriding
iii).Aggregation and containment
d) Create a program that displays the result of a sales transaction. The calculation requires three
numbers. The first number represents the product price. The second number is the salesperson
commission. These two numbers should be added together. The third value represents a customer
discount; subtract this third number from the result of the addition. Create two classes. The first
class, Transaction, contains the method to do the calculation. The three numbers are passed to this
method by a statement in the other class. The display is performed in the class that calls the
calculation method [6 Marks]
Question Four
a) Does garbage collection guarantee that a program will not run out of memory? Support your
Answer [3 Marks]
b) Create a class named Student. A Student has fields for an ID number, number of credit hours
earned, and number of points earned. (For example, many schools compute grade point averages
based on a scale of 4, so a three-credit-hour class in which a student earns an A is worth 12
points.) Include methods to assign values to all fields. A Student also has a field for grade point
average. Include a method to compute the grade point average field by dividing points by credit
hours earned. Write methods to display the values in each Student field.
[6 Marks]
c) Write a class named ShowStudent that instantiates a Student object from the class you
created. Compute the Student grade point average, and then display all the values associated with
the Student. [4 Marks]
d) Create a constructor method for the Student class you created. The constructor should
initialize each Student’s ID number to 9999 and his or her grade point average to 4.0. Write a
program that demonstrates that the constructor works by instantiating an object and displaying the
initial values. [6 Marks]
e) Define the term scope [1 Mark]
Question Five
a) Create a class named Commission that includes three variables: a double sales figure, a
double commission rate, and an integer commission rate. Create two overloaded methods named
computeCommission(). The first method takes two double arguments representing sales and rate,
multiplies them, and then displays the results. The second method takes two arguments: a double
sales figure and an integer commission rate. This method must divide the commission rate figure
by 100.0 before multiplying by the sales figure and displaying the commission. Supply appropriate
values for the variables, and write a main() method that tests each overloaded method.
[12 Marks]
b) Write a program that stores an employee’s hourly pay rate and hours worked. Compute gross
pay (hours times rate), withholding tax, and net pay (gross pay minus withholding tax).
Withholding tax is computed as a percentage of gross pay based on the following:
Gross Pay Withholding Percentage
0 to 300.00 10
300.01 to 400.00 12
400.01 to 500.00 15
500.01 and over 20
[12 Marks]

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

Written by