2008 April Question Paper
2008 April Question Paper
(a) State which object oriented feature ensures code security, and describe two features
found in it. [3]
(i) 16 % 5
(ii) 35 & 12
(ii) 2 << 3
(iv) 17 | 16
(v) 65 >> 2
(ii) What is the keyword used to activate super class method? [1]
(e) (i) Declare a class Oil which contains data members vendor of string type, and price
of double type. [2]
(ii) Implement a constructor to initialize all the attributes of Oil object. [2]
(iii) Implement a method overPrice which will return 4 for price above 100,
otherwise return 1. [2]
(iv) Write java codes to activate method overPrice using object bp of Oil category.
[3]
Page 1 of 5
STRICTLY CONFIDENTIAL
C2005 – April 2008 – QP
(f) Write a method diff with two parameters of double types. It returns the positive
difference of two values. [3]
(g) Write a method count which receives a parameter of an array search of integer data type.
It will return the total number of values greater than 40 found inside the data array. [5]
Page 2 of 5
STRICTLY CONFIDENTIAL
C2005 – April 2008 – QP
(a) Create a class Taxi that includes two attributes, price and seats, of type double and
integer respectively. [3]
(b) Write one public constructor setting the price attribute to 3.50. [2]
(c) Write method getPayment which returns the payments done by the payer where
payment is derived from number of seats multiplied by 3.50. [2]
(d) Write a changePrice method which will return true if the seat is above 10 and increase
the price by another 20% otherwise it will return false. [4]
(e) Write a main program to create object trip of Taxi type. It will activate all the methods
defined in the class. [4]
(a) Define a class called Account which includes a String member called id, and another
member called balance of double type. [3]
(b) Override the default constructor that will initialize the Account object. [3]
(c) Declare an array money that can stored up to 300 accounts. [2]
(d) Write a member method checkbalance that will display any account id that comes with
balance below 3000. [3]
(e) Write a member method called lowestbal. This method should search for and return
smallest balance in the money system. [4]
Page 3 of 5
STRICTLY CONFIDENTIAL
C2005 – April 2008 – QP
(a) Write a code segment to display outputs as stated below by using a while loop. [7]
No
16
12
8
4
Total = 40
(c) State any type of loop that can be used to implement iteration. [1]
(d) Besides Java, state any other two object oriented programming languages. [2]
Page 4 of 5
STRICTLY CONFIDENTIAL
C2005 – April 2008 – QP
(b) Explain any three methods found in String class. Do not mention the methods already
used in part (c). [3]
- END OF PAPER -
Page 5 of 5