State which stament is true?

  1. Cohesionn is the OO principle most closely associated with hiding implementation details

  2. Cohesion is the OO principle most closely associated with making sure that classes know about other classes only through their APIs

  3. None of these

  4. Cohesion is the OO principle most closely associated with making sure that a class is designed witha single well focussed principle


Correct Option: D

AI Explanation

To answer this question, we need to understand the concept of cohesion in object-oriented programming (OO).

Cohesion refers to how closely the responsibilities and behaviors of a class or module are related. It is a measure of how well a class or module is focused on a single purpose or responsibility.

Let's go through each option to understand why it is correct or incorrect:

Option A) Cohesion is the OO principle most closely associated with hiding implementation details. This option is incorrect because hiding implementation details is more closely associated with the principle of encapsulation, not cohesion.

Option B) Cohesion is the OO principle most closely associated with making sure that classes know about other classes only through their APIs. This option is incorrect because the principle described here is actually related to the concept of loose coupling, not cohesion.

Option C) None of these. This option is incorrect because there is a correct answer among the given options.

Option D) Cohesion is the OO principle most closely associated with making sure that a class is designed with a single well-focused purpose. This option is correct because cohesion is indeed the principle associated with ensuring that a class has a clear and specific responsibility.

Therefore, the correct answer is D) Cohesion is the OO principle most closely associated with making sure that a class is designed with a single well-focused principle.

Find more quizzes: