What is the difference between an instance variable and a class variable?
Ans : An instance variable represents a separate data item for each instance of a class, whereas a class variable represents a single data item shared by the class and all its instances. An instance variable represents data for which each instance has its own copy. An instance variable corresponds roughly to a field of a structure (struct) in C or C++. If your program contains twenty Button instances, for example, each instance has its own label instance variable holding the label string for that button. A class variable, in contrast, belongs to the class as a whole. All instances of the class have access to the same single copy. A class variable can therefore function as a shared resource and an indirect means of communication among the instances of the class. Class variables are declared with the static keyword.