5.4 The Structure and Behavior of Methods
1. Explain the difference between formal parameters and actual parameters.
The formal parameters are parameters listed in a method’s definition, and the actual parameters are values passed to a method wen it is invoked.
2. How does Java transmit data by means of parameters?
When a method is called, the value of the actual parameter is automatically transfered to the corresponding formal parameter immediately before the method is activated.
3. Define a method sum. This method expects two integers as parameters and returns the sum of the numbers ranging from the first integer to the second one.
public the Sum(){
int sum;
sum = (int) Math.round (a + b);
debug(”Sum; “average);
retirn sum;
4. What is the purpose of local variables?
It is convenient to have temporary working storage for data in a method.