Thursday 2/19/04
project questions
1. anatomy
of a method
- every method begins with a
- this specifies that the code in the method is
executed only when the method is
-
- a method may be defined
- if it is a class method, only the method name is
required to call it
- Banking.java is
a for
Account.java
- that is, it doesn't do anything particularly useful
itself except
-
2. return
- the return type in a method header can be a
-
- void is
used when a method
-
- methods that have a must have a
- a return statement uses the reserved word return followed by an expression
that dictates the value to be returned
- this returned value must be with
the return type
- note that the return value can be ignored by the
calling program
3. parameters
- the parameter list in the header of a method
specifies
- at the time the method is declared these parameters are called
-
- at the time a method is invoked the values passed to
the method by the calling program are called
- if there are no parameters, then the method is
invoked with an empty set of parentheses
- when calling
a method, the actual parameters must appear in the same order as
the formal parameters
- the only the way complier can enforce this is by
4. constructors
- constructors are methods that
-
- the are unique methods in that
-
- constructors generally initialize or instantiate the
instance variables
- sometimes constructors need parameters to do this
5. local
data
- variable declared is called a local variable
- it's scope is only
- methods can see
-
- but class methods can not see local variables that
belong to