|
Can the display() method see the object's instance variables (such as balance)? A good answer might be:Yes. | |
What Statements can SeeStatements of a method (such as display()) can see the object's instance variables and the object's other methods. They cannot see the parameters (and local variables) of other methods. Here is another look at the CheckingAccount class:
Two methods are using the same identifier, amount, for two different formal parameters. Each method has its own formal parameter completely separate from the other method. This is OK. The scopes of the two parameters do not overlap so the statements in one method cannot "see" the formal parameter of the other method. For example the statement
from the second method can only see the formal parameter of that method---the scope of the formal parameter of the other method does not include this statement. | |
QUESTION 6:Could the two formal parameters which are both named amount be of different types (for example, could one be an int and the other a long)? Click Here after you have answered the question |