The o object is passed to the m method as a hidden parameter. The m method can
refer to this hidden parameter by calling the this reference.
The m static method is called on the C class. Since the method is static, it
does not have direct access to the instance variables and methods of the class. There
is no hidden parameter.
6.11 Important Points
1. Classes represent abstract data types.
2. Class names should start with a capital letter. This distinguishes them from variables
because variables start with a lowercase letter.
3. Objects are instances of classes.
4. Every class has static / instance and public / private variables and methods.
5. Public members of a class (variables and methods) can be accessed from outside the
class. Conversely, private members of a class can only be accessed from within the
class. Note that every method of a class can access the private variables of any object
of the class.
6. Every object (a.k.a., instance) of a class has its own state. The state of an object is
determined by the value of its instance variables.
7. Instance (i.e., non-static) methods of a class contain a hidden parameter. This is an
object of the type of the class where the method appears. Therefore, instance methods
have access to the instance variables of the class. Conversely, static methods have no
hidden parameter and therefore have no direct access to the instance variables of the
8. A static method cannot directly call an instance method. The reason is that every call
to an instance method requires a hidden parameter. However, a static method does
not have such a parameter. Of course, the call o.m() is possible from a static method,
where o is an object that the static method can reference.
9. Every class has a constructor that initializes the instance variables of the class. If
a constructor is not included in a class, then a default constructor that takes no
parameters and does nothing is automatically created.
10. The constructor of a class is a method that has exactly the same name as the name
of the class and no return value (not even void ).
11. All non-constant variables of a class should be defined as private.
12. The objects of classes communicate with each other by calling each other's methods.