// this code demonstrates the concepts of private, public, and static
// variables.

public class Vars
{
  public static void main(String[] args)
  {
  // accessing the instance variables *************************
    System.out.println("a = " + a);   // won't compile. To access "a" one needs
                                    // to instantiate the class Test
    Test t = new Test();              // instantiation of class Test
    System.out.println("a = " + t.a); // now it is OK

    System.out.println("b = " + t.b); // won't compile since b is private

  
  //accessing the class (static) variables **************************
    System.out.println("c = " + Test.c); // first way: via the class name
    System.out.println("c = " + t.c);    // second way: via the instance name
    Test s = new Test();                 // another instance of class Test
    s.c = 20;
    System.out.println("t.c = " + t.c);  // will output 20
    System.out.println("s.c = " + s.c);  // will output 20
   
  
  // the final specifier **************************************
    t.c = 10;                         // won't compile (cannot modify constants)
  }
}

class Test
{
  public int a = 5;             // public instance variable 
  private int b = 7;            // private instance variable
  public static int c = 6;      // static class variable
  public final int d = 8;       // constant definition
}
