After the following statements have executed,
String str = new String("alphabet soup"); int len = str.length();
what value is in the
13. (Remember to count the space character.)
Look again at the second statement, which uses dot notation to specify which method to run:
String str = new String("alphabet soup"); int len = str.length(); | | | | | +---- a parameter list with no parameters | | | +---- the name of the method to run | +---- the reference to the object that contains the method
The second statement contains a method call.
This is a request to run a method of an object.
The object referenced by
contains a method
which, when called,
returns the number of characters in the
length() method does not require any parameters.
The parameter list in the method call
str.length() is empty.
What is wrong with the following code segment?
Point myPoint = new Point(); // construct a point at x=0, y=0 myPoint.move(); // move the point to a new location