Hi all,
given the following:
which is true about the classes described above?
A. Class A is tightly encapsulated.
B. Class B is tightly encapsulated.
C. Classes A and B are both tightly encapsulated.
D. Neither class A nor class B is tightly encapsulated.
The answer is obviously D, but my question is regarding the explanation and the concept in general:
At first glance class B appears to be encapsulated...
Well, the principle of encapsulation says that the class should have all of its state private while providing public getters and setters to access and modify the state. There is only a setter in B, so would we still consider it being tightly encapsulated if foo variable in A were declared private?