Question: Why is it not recommended to make all of a class's variables public?
- Doing so makes your code tightly coupled.
- The attribute may be accessed only by the class that defines the member.
- You will have no control over which values the attribute can take. Any external code will be able to change it without any constraint.
- 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.