Java Reference
In-Depth Information
either a class name or an expression that yields the name of a folder of some
class. (A similar statement can be made about a method call.)
With this introduction, we describe how to determine the variable or method
given by a variable reference or method call during execution of a method body.
1. Find a variable
x
(where
x
is a variable name) or a method for a call
m(
args
)
.
1a:
x
(or
m
) is static. The scope box of the active frame contains
either the name of some class
C
(say) or the name of a folder of
some class
C
. Look for
x
(or suitable method
m
) in
C
's file drawer,
then in the file drawer of its superclass, etc., until it is found.
1b:
x
is a parameter or local variable. Find it in the active frame.
1c:
x
is an instance method. Search the folder whose name is
given in the scope box of the active frame. In searching, start at
the bottom and search upward.
1d:
m(arg)
is an instance method. Search the folder whose name
is given in the scope box of the active frame. In searching, start at
the bottom and search upward.
2. Find a variable for
expression
.x
or a method for a call
expression
.
m(
arguments
)
.
2a:
x
(or
m
) is static. Evaluate expression to yield either a class-
name
C
or a folder of some class
C
. Look for
x
(or suitable method
m
) in
C
's file drawer, then in the file drawer of its superclass, etc.,
until it is found.
2b:
x
is an instance variable. Evaluate
expression
to yield the
name of a folder. Search that folder —start at the bottom and
search upward.
2c:
m
is an instance method. Evaluate
expression
to yield the name
of a folder. Search that folder for a suitable method —start at the
bottom and search upward.
4.7
Abstract classes
Class
Shape
of the previous section might be used incorrectly in two ways:
1. Class
Shape
is present only to provide a superclass of other shape class-
es. Instances of
Shape
should not be created, but creating them is not pro-
hibited.
Lesson
page 4-5
2. Method
drawShape
in class
Shape
should never be called; every subclass
should override it. However, overriding the method cannot be enforced.
Search WWH ::
Custom Search