A class variable can be found on the same location as that of the instance variable. The only difference is that a class variable is declared using keyword static. Using the static modifier will tell the compiler that this variable has only one copy in existence. So regardless of how many copy of a class is created, there would be only one value of this variable. Since the class variable is static, it should be accessed statically. Taking a look on the DeskFan example, we have declare a class variable as
static int voltage = 220;
. In order for us to access the voltage variable we should used the ClassName for example
If we add another modifier final, the variabke voltage is now considered constant which means to say this variable cannot be changed.