|
What does the expression
A good answer might be:The expression means to use the variable accountNumber that is part of the object referred to by account1. | |
What Parts of an Object can be Seen?The dot operator is how you access a part of an object: referenceToAnObject . partOfTheObject Of course, an object has to exist, and there has to be a reference to it. In the program, this happed when the the object was constructed:
When a method has a reference to an object, the the method can:
However it is common for a class have private variables and methods. Only methods of the class can access these. This will be discussed further in the next chapter. To begin with, our programs will look like this, all in one source file:
| |
QUESTION 9:Can the main() method of TesterClass see the statements in the methods of SomeClass? Click Here after you have answered the question |