Computers Quiz
Class Variable
Always defined in a class and not inside a method. * They are always static. * They can be either or public or private. * There is only one copy shared by every instance of the class. * If I have 7300 Cats then I will have one copy of numberOfLegs. * * The scope of class variables is the entire class. Class variables can be * used inside both static and non-static methods. * aka static variables
Instance Variable
Always defined inside a class and not inside a method. * They are never static. * They are usually private but they can be public. If you don't * specify by default they are public * There is one copy of this variable for every instance of the object!!!!! * If I have 7300 Cats then I need 7300 variables to store the name of the cat. * aka State aka non-static variable
Local Variable
They are always defined in a method or they are the input into a method. * String c is a local variable because it was declared inside a method * They are never static because this is ridiculous. * There is only one copy of a local variable that exists only while the method is executing * They never public or private - this is an absurd concept for a local variable. * * The scope of a local variable is the method where it is declared, although the scope * may be even more limited that. For example, if you declare a variable in the body of * an if statement its scope is that if statement.