Page 6 - KMK PREPSPM2 1819 ANSWER
P. 6
SULIT No. Matrik…………………………………….… No. Kad Pengenalan………………………….. SC015
4 (a) A method is simply a task or process. Thus, each method represents a single
process. Each process by itself consists of many steps. Each method returns a
single value. Each method can receive one or more values to start the task via
its parameters. Methods are also known as functions.
(i) Explain the meaning of method.
[1 mark]
Method is a collection of statements that are grouped together to
perform a process/task.
(ii) Explain one (1) advantage of using method.
[2 marks]
Code Reusability
You can write a method once, and use it multiple times
(iii) State two (2) types of method.
[2 marks]
Standard Library Method
User-defined Method
(iv) Identify the type of method used in the Java statement below.
Math.pow(5,2);
[1 mark]
Standard Library Method
(v) Given the method definition as follows:
double getAverageMark(double mark1, double mark2){
return (mark1+mark2)/3;
}
Identify the method components.
[3 marks]
Return Type : double
Method Name : getAverageMark
Parameters : mark1, mark2
6 SULIT

