Variables Flashcards
Local variables
A variable inside of a method or constructor that can’t be accessed outside of that method or constructor. It must be assigned before it is used.
Instance variables
Instance variables are the attributes of the object. They change based on which instance of the class you are looking at.
Numbers are initialized to 0.
Reference variables are initialed to null.
Static variables
Static variables are special because they do not need to be called on a specific object of a class, but can be called on the class. They are constants that don’t change. For example, Integer.MAX_VALUE;
Numbers are initialized to 0.
Reference variables are initialed to null.
Reference variables
They point to objects( Including things like Cat, String, and Integer, but not int, char, or other primitive types.
Primitive variables
They point to primitive values like int, char, long, and double.
Formal parameters/method parameters
These are the types and names of the parameters in a method.
Actual parameters
These are the values passed in to a method
Access Specifiers
The ‘public’ or ‘private’ at the beginning of methods or classes that tell where it can be accessed.
public
Once the class is imported, can be used
Private
Can not be used outside of the class, imported or not
encapsulation
This is when you hide some unnecessary details for users by making methods and other things private.
Declaring Class
The class a method is in
mutator/setter methods
methods that allow users to change an instance variable according to the code inside.
accessor/getter
Methods that allow users to see a instance variable, but not change it.