cri
Answered On : Sep 9th, 2012
A class variable is a variable that is declared as static. This variable can be accessed even before the object of the class is created. i.e it would be available when the class is loaded. Where as instance variable is a variable that is declared at class level without the keyword static.
Login to rate this answer.
A class variable which is declared as static is common to all the instances of the Class, i.e if you make any change in the class variable it applies to all the objects created for the class. In case of Instance variable- each object created for the class has its own instance variable copy.
Login to rate this answer.
arvindkore
Answered On : Oct 8th, 2012
class variable is static variable is create when class structure is defined ,and other variables which are create and destroyed with object are called instance variables
Login to rate this answer.
Static variable, the field is allocated when the class is created. It belongs to the class and not any object of the class. It is class variable.
Instance variable, the field is allocated when the class is instantiated to the class is called instance variable or non-static variable
Static variable has only one copy for all the methods in class while instance variable has many copy.
Class can access only static variable while object can access both class and instance variable.
Login to rate this answer.