revised 10/09/98; 09/04/99; 01/20/00

CHAPTER 28 ---Parameters in Method Calls

An object contains both variables and methods. Often when you use a method, you need to give it some information which says exactly what you want to happen. For example:

Point pt = new Point();

pt.move( 14, 22 );              // move pt to x=14, y=22
The move method must be used with two parameters that give the x and the y value of the new location of the point.

Chapter Topics:

  • Methods with no parameters.
  • Parameter lists.
  • Data types of parameters.
  • Expressions in parameter lists.
  • Conversion of values in parameter lists to required types.

QUESTION 1:

After the following statements have executed,

String str = new String("alphabet soup");
int    len = str.length();
what value is in the variable len?

Click Here after you have answered the question