A good answer might be:

Yes—since each can only be seen in the body of its method, each can be declared to be of any type.


One-way Glass

It is sometimes useful to visualize methods as surrounded by a box of "one-way glass." A method can see local variables and parameters that are inside the box. A method can see out of the glass that surrounds it. But no outsider can see into the box.

The picture shows the one-way glass for the example program. The red lines show the box of one-way glass surrounding each method. The method can see out of its box (for example each method can see the instance variable balance) but other methods can't see from the outside into the box of one-way glass.

In processDeposit() the statement can "see" the variable balance declared as a member variable. It can also see the parameter amount that is inside its box.

The method showCharge() is defective because it contains a statement that attempts to look inside the box that surrounds processCheck().

The names formal parameters (such as amount) and local variables (such as charge) are only visible from inside the glass box. However, the number and type of actual parameters required for each method is known by outsiders.



QUESTION 7:

Is the name of a method inside or outside the glass box?