Beruflich Dokumente
Kultur Dokumente
INSTRUCTIONS TO CANDIDATES
1. This question paper consists of TWO (2) parts : PART A (15 Questions)
PART B ( 6 Questions)
4. Please check to make sure that this examination pack consists of:
A. a series of rules.
B. a series of facts.
C. logical statement.
D. All the above.
A. P2 implies P1.
B. P1 implies P2.
C. P1 is disjunction with P2.
D. P2 is conjunction with P1.
3. Inheritance
(/ ( * 1 2 3 4 ) ( + -3 -2 - 1 0) )
A. -4
B. 4
C. 0
D. 24
A. private
B. dynamic
C. protected
D. static
9. The following are the access modifiers that can be used for constructor EXCEPT
A. public.
B. protected.
C. private.
D. final.
10. Variables in Prolog are introduced as strings of characters starting with a first letter
which is a(n)
A. small letter.
B. capital letter.
C. predicate.
D. atom.
A. yes
B. no
C. ok
D. continue
A. searching mechanism.
B. go-to statements.
C. if-then-else statements.
D. do-loops, for-loops, and while-loops.
13.
A. 3 X Q
B. V X Q
C. ! X Q
D. % X Q
A. are
B. hungry
C. are you hungry
D. ()
A. today
B. is
C. it
D. is cloudy today
QUESTION 1
a) Logic and Functional Paradigm are the two main paradigms of computer languages.
For each paradigm, briefly explains the THREE (3) key features and gives an
example of a computer language that is categorized in the paradigm.
(6 marks)
b) Briefly explain the following terms:
i) Dynamic binding,
ii) Lambda function.
(4 marks)
QUESTION 2
Examine the following codes written in C++ language and answer the following questions:
#include <iostream.h>
void main()
int count;
int numEven, numOdd;
numEven = numOdd = 0;
count = 0;
while(count < 10)
if(numbers[count] % 2 == 0)
++numEven;
else
++numOdd;
++count;
b) What is the initial value and final value for the following variables?
i) count
ii) numEven
iii) numOdd
(6 marks)
QUESTION 3
Write a generic function to find the average of the numbers in an integer array. This function
should receive two arrays of integer values.
QUESTION 4
class Owner
{
private String name;
private String address;
public Owner(){} //default constructor
class Vehicle
{
private Owner own;
private String regNum;
public Vehicle (){} //default constructor
ii) vehicle's information such the as owner's name and registration number i.e.
"Amir Syakir", "WJC305".
(4 marks)
c) Modify class V e h i c l e above, in order to add more information about the vehicle
such as year of manufacture, purchase price and age of the vehicle.
(6 marks)
d) Add a new method to calculate the current price for a particular vehicle based on the
depreciation of the car value (Price). Assumed that the depreciation rate is about
10% a year.
(8 marks)
QUESTION 5
valuejneal(10.00).
family_meal(30.00).
party_meal(45.00) .
kid m e a l ( 5 . 0 0 ) .
served as(takeaway).
served as(eat h e r e ) .
ii) A promotion that will return a type of meal and its cost is based on the
number of person.
(2 marks)
ii) What is the bill for a person that orders a value_meal and sof t _ d r i n k s ?
(1 mark)
QUESTION 6
a) Entry fees for a child in an animal road-show is RM3 while the entry fees for an adult
is RM6. One family consists of n family members and m of them is children.
i) Write the entry fees function for the case above using Scheme.
(4 marks)
ii) If Irfan's family consists of 6 members and 4 of them are children, show the
output for the entry fees for this family using the answer in a)i) above.
(2 marks)
i) CV2
1^ =
V
(2 marks)