Could the two formal parameters which are both named amount be of different types?

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 each method as surrounded by "one-way glass." The method can see out of the glass that surrounds it, but no outsider can see inside. 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.

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?

Click Here after you have answered the question