The rules of encapsulation are:
** All instance variables (state) are private
** To access/modify the state selectors/modifiers methods are provided
** The naming convention follows JavaBean naming convention (setSomething() and getSomething())
Of these three, the mandatory are keeping state private and providing setters for modification. If class A is not tightly encapsulated, that usually means that some of its state or the variables it inherits are not private. Every class that subclasses A will have access to inherited public or protected fields of A, which undermines the encapsulation concept. In some cases though, it's hard to see unambiguously whether a subclass is encapsulated or not. Consider this example:
Class A is apparently not tightly encapsulated because
name is marked default access. Any class inside pack1 can modify it directly. Class Child is not encapsulated either due to this flaw. But what if Child is defined in a separate package pack2? All of a sudden, it looks very much like complying with the concept.
name is not directly accessible any more! I hope, I'm not introducing more confusion here, the questions on the exam were not as dubious as my example.
