CSC435_OCT2022_Test1_Q
CSC435_OCT2022_Test1_Q
INSTRUCTIONS TO CANDIDATES
2. Answer ALL questions from PART A, and PART B in this question paper.
Name/UiTM No.:
Group/Lecturer.:
Part A 20
Part B 30
TOTAL MARKS 50
A. I, II
B. I, IV
C. I, II, III
D. I, III, IV
A. Data hiding
B. Encapsulation
C. Inheritance
D. Polymorphism
5. Which of the following options leads to the portability and security of Java language?
6. Given the following code fraction, what is the output after execution?
System.out.println(word2);
}
A. “hello”
B. “olleh”
C. “heoll”
D. “ollhe”
7. Java supports three types of variables: class or static variables, non-static or instance
variables and local variables. Which of the following is TRUE about class or static
variables?
8. Which of the following methods changes the data of an employee object? Assume an
employee has an id number and a name.
9. It is a logical template to create objects that share common attributes and methods.
The definition most likely refers to ___________.
A. an interface
B. an inheritance
C. a class
D. an array
10. Given a program segment below. What is the output after the statements execute?
if (cust2 == cust1)
System.out.print(“YES ”);
else
System.out.print(“NO ”);
System.out.println(“THANK YOU ”);
…..
}
}
a) This year (2022), Suruhanjaya Pilihan Raya Malaysia (SPR) is identifying which
channel (saluran) voters should be. Write a structured Java program (without using
object-oriented approach) to:
b) Assume that you are currently developing a self-checkout system for a grocery shop.
The system will be able to scan products and calculate the total price to pay. Customers
can pay via card or e-wallet.
Identify ONE (1) possible class and TWO (2) proper attributes for the class that can be
developed for the system.
(3 marks)
……
1 (1-bed) 300
2 (2-bed) 250
4 (4-bed) 100
(4 marks)
b) A main class is then written to test the class above. Complete this main class by:
(Assume all getters and setters have been defined for all attributes)
ii) Calculate and display the average charges for all patients
(4 marks)
iii) Find the highest charge among all patients in the array and display the
(3 marks)
import java.io.File;
catch (Exc
END OF QUESTION PAPER