- breaking down a program into subprograms in
form of a method or function (top) and specifying its details (down) after.
• What
is a method?
-it is a subroutine that group related
statements together and/or protect data from direct access.
2 types of method or
function
• built-in
method
• user-defined
method
2. 4
types of user-defined method
• Method
that has no parameter and return no value.
example:
void header(){
//statements
}
• Method
that has no parameter and return a value.
example:
int readIntegerInput(){
//statements..
return <value>
}
• Method
that has parameter and return no value.
example:
void Write(String str){
//statements either to process or display
parameter
}
• Method
that has parameter and return a value.
example:
int ComputeSum(int n1, int n2){
//statements either to process or display
parameter
return <value>
}
No comments:
Post a Comment