Java Reference
In-Depth Information
7.3
Static Class Members
SR 7.6
Memory space for an instance variable is created for each object that is
instantiated from a class. A static variable is shared among all objects
of a class.
SR 7.7
Assuming you decide to use the identifier
totalBalance
, the declaration is:
private static int
totalBalance = 0;
SR 7.8
Assuming that the minimum required is 100 and you decide to use the
identifier
MIN_BALANCE
, the declaration is:
public static final int
MIN_BALANCE = 100;
SR 7.9
The
main
method of any program is static, and can refer only to static
or local variables. Therefore, a
main
method could not refer to instance
variables declared at the class level.
7.4
Class Relationships
SR 7.10
A dependency relationship between two classes occurs when one class
relies on the functionality of the other. It is often referred to as a “uses”
relationship.
SR 7.11
A method executed through an object might take as a parameter
another object created from the same class. For example, the
concat
method of the
String
class is executed through one
String
object and
takes another
String
object as a parameter.
SR 7.12
An aggregate object is an object that has other objects as instance data.
That is, an aggregate object is one that is made up of other objects.
SR 7.13
The
this
reference always refers to the currently executing object. A
non-static method of a class is written generically for all objects of the
class, but it is invoked through a particular object. The
this
reference,
therefore, refers to the object through which that method is currently
being executed.
7.5
Interfaces
SR 7.14
A class can be instantiated; an interface cannot. An interface contains a
set of abstract methods for which a class provides the implementation.
SR 7.15
public interface
Nameable
{
public void
setName (String name);
public
String getName();
}
Search WWH ::
Custom Search