Variables associated with the instance of a class are called instance variables. Whenever a class is instantiated, the runtime system creates a separate copy of each instance variable defined by the class. Therefore, each instance of a class has its own copy of all instance variables defined by the class.
If an instance variable is in the scope, it can be accessed simply by its name. However, if it is not in the scope, it is accessed by its name qualified by the object reference along with a dot operator as shown below:
where, objreference is the name of the variable holding the reference of the object and instancevar is the name of the instance variable associated with that object.
- Pass SCJA in first attampt.
- Download free practice test for SUN SCJA exam.
- Click here to download 310-035 test study guide and practice question.
- Download free practice test for SUN SCJP 1.4 Upgrade exam.
- Become SUN Java 5.0 certified.
- Pass SUN CX310-056 - SCJP 5.0 Java Upgrade
- Pass SCJP 6.0 in first attampt.
- Click here to download CX310-066 test study guide and practice question.