|
What is printed to the monitor by the above program? A good answer might be:
The string is 15 characters long |
Invoking an Object's MethodRemember that an object consists of both variables (state information) and methods (recipies for behavior.) Both of these are called "members" of the object. Java uses "dot notation" for both: For example, to invoke the length() method of the object named str1 the following is used:referenceToAnObject.memberOfObject
Remember that all method names will have "()" at their end.
The above method evaluates to an integer, 15, which is assigned to
the int variable len.
|
QUESTION 10:(Thought Question:) Is it possible for a program to have several objects all of the same class? Click Here after you have answered the question |