Scope
- Scope refers to the lifetime of a variable.
- There are four basic scopes:
- Static variables live basically as long as their class lives.
- Instance variables live as long as their object lives.
- Local variables live as long as their method is on the stack; however, if their method invokes another method, they are temporarily unavailable.
- Block variables (e.g., in a for or an if) live until the block completes.