1) Class A has a Class D 2)Methods in Class A use public methods in Class B 3)Methods in class C use public methods in class A 4)Methods in class A use variables in class C. What is most likely true?

  1. Class D has low Cohesion

  2. Class B has weak encapsulation

  3. Class A has weak encapsulation

  4. Class B has strong encapsulation


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Class D has low Cohesion - This option is not necessarily true based on the given information. Cohesion refers to the degree to which the elements within a module (class) belong together. The given information does not provide any indication of the cohesion of Class D.

Option B) Class B has weak encapsulation - This option is the correct answer. Encapsulation refers to the bundling of data and methods within a class, hiding the internal implementation details. The given information states that the methods in Class A use public methods in Class B. This implies that the internal implementation details of Class B are exposed and accessible to Class A, indicating weak encapsulation.

Option C) Class A has weak encapsulation - This option is not supported by the given information. The methods in Class A are using public methods in Class B, indicating a dependency on Class B, but it does not necessarily imply weak encapsulation in Class A.

Option D) Class B has strong encapsulation - This option is not supported by the given information. The methods in Class A are using public methods in Class B, indicating a dependency on Class B, but it does not necessarily imply strong encapsulation in Class B.

The correct answer is B) Class B has weak encapsulation. This option is correct because the given information states that the methods in Class A use public methods in Class B, indicating that the internal implementation details of Class B are exposed and accessible to Class A.

Find more quizzes: