Scope of Instance & Class (static) variables in Java

  1. Variables in a program can only be accessed in certain parts of the program
    (not from anywhere in the program)

  2. Scope of a variable:


  3. There are two types of scoping rules in Java:



  4. Scope of Instance & Class (static) variables are controlled by access modifiers:

    NOTE: It is a customary practice of OOP style to make all instance & static variables private