Variables can be volatile or non-volatile. Volatile variables lose their value on power-off. Non-volatile variables keep their value even after power-off.
Variables are local to the component or method in which they are declared. Should it be necessary to set or view the variable outside of the component, the variable needs to be connected to a Register.