For example, if we have the declaration
Time bomb;
then anywhere within the scope of the object bomb, we can access any of bomb's public members, as defined in the Time class.
The strategy is to insulate users of the class from its implementation details. For example, we could implement the Time class with only 1 instance variable,
private int seconds; // 0 <= seconds <= 60 * 60 * 24
without changing what the methods deliver to clients.
We can change our implementation in many ways without having to change client code.
A method should be declared private when the intention is for it to be invoked only by the class's methods (i.e., it is a utility method).
It initializes the instance variables of objects in the class.
A class usually has several constructors, each with a unique parameter list (i.e., the constructor typically is an overloaded method).
Constructors cannot return a value.
Java consequently is referred to as an extensible language.
Time HappyHour, squashSchedule[], renAndStimpy, PeteAndPete;
The constructor for Time invokes the setTime method to initialize the instance variables to 0.
Designing classes this way eliminates a major source of errors, making object-oriented programming less error-prone than, say, ordinary C programming.
They have access to all instance variables implicitly.
This feature keeps method argument lists short, and less likely to have type errors at compile-time.