Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Explain the difference between formal parameters and actual parameters. 2. Ho

ID: 3527381 • Letter: 1

Question

1. Explain the difference between formal parameters and actual parameters. 2. How does Java transmit data by means of parameters? 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. 4. What is the purpose of local variables? 5. What are the lifetimes of an instance variable, a local variable, and a parameter? 6. What is shadowing? Give an example and describe the problems that shadowing might cause in a program.

Explanation / Answer

The variables declared in the procedure and which are passed, as arguments are called actual, the parameters in the procedure declaration. Actual parameters contain the values that are passed to a procedure and receive results. Formal parameters are the placeholders for the values of actual parameters I believe that much of the confusion on this issue has to do with the fact that different people have different definitions of the term "reference". People coming from a C++ background assume that "reference" must mean what it meant in C++, people from a C background assume "reference" must be the same as "pointer" in their language, and so on. Whether it's correct to say that Java passes by reference really depends on what's meant by "reference"