[go: up one dir, main page]

0% found this document useful (0 votes)
7 views2 pages

1 Def Function It Is A Subprogram W

Uploaded by

train2data01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

1 Def Function It Is A Subprogram W

Uploaded by

train2data01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1 def: function: It is a subprogram which performs a small task.

or
it is a self contained block which performs a specific task.

2 advantage: code reusability.

3 property of the function: function always returns only 1 values. function can't
return more than 1 value.

4 types of functions
functions are of 2 types
1) system defined functions: A function which is already created along with the
software is called system defined functions.
eg: system.debug()
math.mod()

2) user defined functions: A function which is created by developer as per the


business need.

5 parts of the functions


**********************
function contains 2 parts

1) Calling Point: it contains 3 parts


1) function name/method name
2) list of arguments
3) ;

2) Definition Point: it contains 2 parts


a) function / method header-- 3 parts
1) return type
2) function name/ method name
3) list of args.
b) function / method body
{

actual logic

}
6) functions are further divided into 4 types depending on receive and return the
values.

1) receive and return the values.


Integer num1 = 10, num2 = 20,result;
result = addition(num1,num2);
system.debug('the sum is ' + result);
num1 = 100;
num2 = 200;
result = addition(num1,num2);
system.debug('the sum is ' + result);

Integer addition(Integer x, Integer y){


Integer z; // local variable
z = x + y;
return z;
}
2) receive but doesn't return the value.
Integer num1 = 10, num2 = 20;
addition(num1,num2);

void addition(Integer x, Integer y){


Integer z,m; // local variable
z = x + y;
m = x - y;
system.debug('the sum is ' + z);
system.debug('the subtraction is '+ m);
}

3) doesn't receive but returns the value.

Integer result;
result = addition();
system.debug('the sum is ' + result);

integer addition(){
Integer z=10,m=20; // local variable
return(z+m);
}

4) doesn't receive and doesn't return the value.

fun();

void fun(){
system.debug('Durga Soft solutions');
}

You might also like