What are instance variables?

August 8th, 2009 by uCertify Leave a reply »

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:

objreference.instancevar

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.

Note: Instance variables are initialized with the default values when the class is instantiated.

Like this article? Share it with others
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.
  • Share/Bookmark
Advertisement

Leave a Reply

uCertify.com | Our Company | Articles | Contact Us | News and Press Release | uCertify India | Entries (RSS)
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD    Cisco Certification: CCNA, CCENT    A+, Network+, Security+ Project+
Oracle Certification: OCP 11g, OCP 10g, OCA 11g, OCA 10g    CIW foundation    EC-212-32,    CISSP    Photoshop ACE CS4    Adobe Flash ACE, PMP, CAPM
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.