|
Presentation slides are copyright 2002 by John Lewis and William Loftus. All rights reserved.
Instructors using the textbook may use and modify these slides for pedagogical purposes.
|
u ow we can explore various aspects of classes and
objects in more detail
¢
D
u Decall from Chapter 2 that an object reference
variable holds the memory address of an object
-
r
D
u An object reference variable that does not currently
point to an object is called a
u The reserved word can be used to explicitly set
a null reference:
§
#
#
)
# ) )
`
D
u For object references, assignment copies the
memory location:
#
§
#
#
v
u Two or more references that refer to the same object
are called pp of each other
r
u The == operator compares object references for
equality, returning if the references are aliases
of each other
#
* #
u Java performs p
p uppu
periodically, returning an object's memory to the
system for future use
¢
u Parameters in a Java method are ?p
p
-
!
u The order of the modifiers can be interchanged, but
by convention visibility modifiers come first
u Decall that the method is static; it is invoked by
the system without creating an object
`
r
u Static methods and static variables often work
together
u For example
%%."
%#/
u The
O p of a method header indicates what
exceptions it may throw
Enclosing Class
ested Class
|
u A nested class has access to the variables and
methods of the enclosing class, even if they are
declared private
.8
|
u A nonstatic nested class is called an p
u An p p
is a method header without a
method body
A semicolon immediately
follows each method header
u An interface cannot be instantiated
::
(
u A class that implements an interface can implement
other methods as well
u A GUI
?
defines a screen element to
display information or allow the user to interact with
the program
Ñ buttons, text fields, labels, menus, etc.
u A
p is a special component that holds and
organizes other components
Ñ dialog boxes, applets, frames, panels, etc.
u An is an object that represents some activity to
which we may want to respond
| °
u A ?
is a component that allows the user to
initiate an action with the press of the mouse button
Ñ defined by the 0 class
Ñ generates an p
u A 0 generates an p