WorksheetsMethod
Total questions: 15
Worksheet time: 3mins
Describe method.
A component of a program in a big program.
A program to perform a specific task.
A component of a program written to perform a specific task.
A variable that use to read an input.
There two (2) types of method which are
return
Pre-defined
User defined
non-return
Which one is a general structure of method.
<Returnvalue type> <Method Name> (argument / s)
<Modifier> < type> <Method Name> (parameter / s)
public static void main (String[ ] args)
<Method Name> (parameter)
This is an example of a non-return method.
True
False
In which line is representing the meaning of Pre-defined method.
Line 2
Line 8
Line 13
Line 10
Method make codes more readable and easier to debug.
True
False
The name of this method is ....
Oddsum
oddsum
int Oddsum (int number)
return totaloddsum
Data type for non return method is
int
double
void
public static
List all arguments that exist in this program segment:-
double point, String student
point, student
name, mark
name[i], mark[i]
List all parameters that exist in this program segment:-
double point, String student
point, student
name, mark
name[i], mark[i]
Create a method name Bonus that will read a basic payment and an hour variable as parameter to calculate an extra salary.
What is the Output if the argument is (5500.00, 12.5)
There will be no output.
20, 625.00
27,500.00
34,375.00
What is the Output if the argument is (1300.00, 15.0)
9,750.00
7,800.00
There will be no output.
5,850.00
What is the Output if the argument is (1000.00, 14.30)
4,290.00
5,720.00
7,150.00
There will be no output.
Why method is important?
Break program into a small program and easy to debug.
Easier to read and understand aspecially when involving with a big program.
More practical when we need to reuse the code.
Can store more similar values in a single variable.
