I always thought a client of a class is one that uses a reference to access instance fields/methods of that class i.e. another class (from its own methods). But when I think about some details there are some things that I couldn't figure out.
In Java I know of a few places where you can place action statements.
- Inside a method (instance/static)
- Inline initialization (when you declare an instance variable like in private int x = 5;)
- Static block
Maybe there are more that I don't know or remember.
The first part of the question is are all of these considered clients if they are in another class? Also can they access private stuff when they are in the same class?
The second part is: When JVM calls a method (like main and finalize) are they considered clients, too? (the calls are not from a class?)
Edit: Can a client access only public methods and variables? Can't we call it a client if it accesses package fields (if in the same package).