Java OCA OCP Practice Question 1178

Question

Which of the following is not a reason to use encapsulation when designing a class?

  • A. Promote usability by other developers.
  • B. Maintain class data integrity of data elements.
  • C. Prevent users from modifying the internal attributes of a class.
  • D. Increase concurrency and improve performance.


D.

Note

Implementing encapsulation prevents internal attributes of a class from being modified directly, so Option C is a true statement.

By preventing access to internal attributes, we can also maintain class data integrity between elements, making Option B a true statement.

Option A is also a true statement about encapsulation, since well-encapsulated classes are often easier to use.

Option D is an incorrect statement.




PreviousNext

Related