CSC186 FinalDec2019
CSC186 FinalDec2019
TIME 3 HOURS
INSTRUCTIONS TO CANDIDATES
1. This question paper consists of two (2) parts : PART A (20 Questions)
PART B (4 Questions)
3. Do not bring any material into the examination room unless permission is given by the
invigilator.
4. Please check to make sure that this examination pack consists of:
PART A
2. A constructor is
4. The values of a private attribute is made accessible to outside client programs with the
use of .
a) mutator method
b) accessor method
c) processor method
d) tostring method
6. Which of the following is the CORRECT parameter type and sequence for the Car
constructor?
7. Composite object is .
11. What will be displayed when the following codes are executed?
biskid.cost[0] = 19.90;
biskid.cost[l] = 20.00;
biskid.cost[2] = 10.50;
biskid.cost[3] = 9.20;
for (int i=l; i<3; i++)
sum = sum + biskid.cost[i];
System.out.print("Total cost: " + sum);
Which is the CORRECT statement to calculate the sum of three (3) Fraction instances
fl, f2 and f3?
a) polymorphism
b) overloaded method
c) overriding method
d) interfaces
a) public person (int id, String name, int dd, int mm, int
yy){this.id = id; this.name = name; this.dd = dd; this.mm = mm;
this.yy = yy;}
b) public person (int id, String name, int dd, int mm, int
yy){super(dd,mm,yy); this.id = id; this.name = name;}
c) public person (int id. String name, int dd, int mm, int
yy) {student = new Student(id, name); date = new Date(dd, mm,
yy);}
d) public person (int id, String name, int dd, int mm, int
yy){super(id, name); Date(dd, mm, yy);}
cat ;
cat display();
a) Siamese
b) Persian
c) Himalayan
d) Cat
19.The following diagram is the inheritance structure for PublicTransport, lrt and
mrt classes:
PublicTransport
MRT LRT
class Flower {
public Flower(){
System.out.println("The default constructor of Flower is
invoked")}
}
(40 MARKS)
PARTB
QUESTION 1
//constructor
//mutator
//accessor
//toString()
}
Based on the above information, write the statement for the following tasks:
b) In class application, write the statements to display publisher's name through the fourth
character of the bookCode (e.g BKC1147 is published by Course Pubs).
(60 MARKS)
QUESTION 2
Sedap Bak Hang Catering Services offers attractive packages for the coming school holidays
as stated in a table below. In order to provide efficient service to customer, the company
decided to develop an ordering system that consists of 2 classes; Order and Date.
i) Method calcPrice () that will calculate and return the total price based on the
selected packages and number of customers. If the number of customers is more
than 1000, a 10% discount is deducted from the total price.
(3 marks)
ii) Method calcPrice (double disc) that will calculate and return the total price
based on the selected packages, number of customers and discount given during
promotion period. Discount given depends on management decision.
(2 marks)
i Hak Cipta Universiti Teknologi MARA CONFIDENTIAL
CONFIDENTIAL 10 CS/DEC 2019/CSC186
iii) Method isExpensive (Order) that receives second object of Order as a parameter
and returns true or false. This method compares the total price of two Order objects
during non-promotion period. This method returns true if first object is more
expensive than second object otherwise returns false.
(2 marks)
QUESTION 3
Sewa4U Online provides rental services for terrace houses and condominium units. The
company needs a system to handle its monthly rental collections from tenants. The following
class is used to represent a house for rent.
public House( ){ }
The class should also have a method to calculate and return the rent based on the
following table:
(6 marks)
QUESTION 4
Cinta Sayang Tailoring offers custom-made men's and women's fashion such as baju
melayu, baju kurung, coats, blazer, jackets and many more. As for the first phase, the
ordering system focuses on baju melayu and baju kurung only. The following are classes
and inheritance hierarchy for its ordering system.
TailorOrder
BajuKurung BajuMelayu
i) Declare an array of objects based on customer order. The number of customer orders
is determined by user.
(2 marks)
ii) Calculate and display the number of customer orders for Baju Kurung with
embroidery.
(4.5 marks)
iii) Calculate and display the payment for each order. Ifthe customer requests delivery,
additional charge of RM5.00 has to be included in the payment. Calculate and display
the total payment for all orders. Display the output in the following format:
Total :RM
(6.5 marks)