1. You DID declare _mood. It is a class variable of the class Static2.
2. You only have ONE static method (not counting the main method): public static int instances() Everytime you create an instance of Static2, the variable _instantiations is increased. instances() returns its value.
Static methods can be accessed without needing an instance of the class.
Static variables can also be accessed without a instance. They also have the same value for all instances.
example:
.
.
.
System.out.println(Static2.instances()); //output will be "0".
Static2 s1 = new Static2(); //increases the counter
System.out.println(Static2.instances()); //output will be "1"
System.out.println(s1.instances()); //output will be "1"
Static2 s2 = new Static2(); //increases the counter
System.out.println(Static2.instances()); //output will be "2"
System.out.println(s2.instances()); //output will be "2"
System.out.println(s2.instances()); //output will be "2"
Note that the static variable _instantiations is the same for all instances.
The NON static variable _mood is NOT the same for all instances as you will see executing your example.