Question: Why is it not recommended to make all of a class's variables public?

  1. Doing so makes your code tightly coupled.
  2. The attribute may be accessed only by the class that defines the member.
  3. You will have no control over which values the attribute can take. Any external code will be able to change it without any constraint.
  4. You can then access the attribute only within the class itself, and by inheriting and parent classes.

Answer: The correct answer of the above question is Option C:You will have no control over which values the attribute can take. Any external code will be able to change it without any constraint.