Java Reference
In-Depth Information
￿ An identifier x declared within a method (block) is accessible:
￿ Only within the block from the point at which it is declared until
the end of the block.
￿ By those blocks that are nested within that block.
￿ Suppose x is an identifier declared within a class and outside every
method's definition (block):
￿ If x is declared without the reserved word static (such as a named
constant or a method name), then it cannot be accessed within a
static method.
￿ If x is declared with the reserved word static (such as a named
constant or a method name), then it can be accessed within a
method (block), provided the method (block) does not have any
other identifier named x .
38 . Two methods are said to have different formal parameter lists if both
methods have:
￿ A different number of formal parameters, or
￿ If the number of formal parameters is the same, then the data type of the
formal parameters, in the order you list, must differ in at least one
position.
39 . The signature of a method consists of the method name and its formal
parameter list. Two methods have different signatures if they have either
different names or different formal parameter lists.
7
40 .
If a method is overloaded, then in a call to that method, the signature, that
is, the formal parameter list of the method, determines which method to
execute.
EXERCISES
1. Mark the following statements as true or false:
a. To use a predefined method of a class contained in the package
java.lang in a program, you only need to know what the name of
the method is and how to use it.
b. A value-returning method returns only one value via the return
statement.
Parameters allow you to use different values each time the method is
called.
c.
 
Search WWH ::




Custom Search