文档介绍:×÷Õߣºjeru
email: jeru@
ÈÕÆÚ£º7/3/2001 9:59:34 AM
Objective 2
Declare classes, inner classes, methods, instance variables static, variables and automatic (method local) variables, making appropriate use of all permitted modifiers (such as public final static abstract and so forth). State the significance of each of these modifiers both singly and bination and state the effect of package relationships on declared items qualified by these modifiers.
Two types of variables.
Member variables
¡¤ Accessible anywhere in the class.
¡¤ Automatically initialized before invoking any constructor.
¡¤ Static variables are initialized at class load time.
¡¤ Can have the same name as the class.
Automatic variables(method local)
¡¤ Must be initialized explicitly. (compiler will catch it when using, but doesn¡¯t catch it if no using) Object references can be initialized to null to make piler happy.
¡¤ Can have the same name as a member variable, resolution is based on scope.
¡¤ Can only be final. Not other modifiers.
Modifiers are Java keywords that provide information piler about the nature of the code, data and classes. The visibility modifiers are part of the encapsulation mechanism for Java. Encapsulation allows separation of the interface from the implementation of methods.
Access modifiers ¨C public, protected, private
¡¤ Only applied to class level variables. (Method vari