Multiple choice technology web technology

Given: ClassA has a ClassD Methods in ClassA use public methods in ClassB Methods in ClassC use public methods in ClassA Methods in ClassA use public variables in ClassB Which is most likely true? (Choose the most likely.)

  1. ClassD has low cohesion

  2. ClassA has weak encapsulation

  3. ClassB has weak encapsulation

  4. ClassB has strong encapsulation

  5. ClassC is tightly coupled to ClassA

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Direct access to another class's public variables violates encapsulation principles. ClassB should protect its data with private fields and provide access through getter/setter methods, making ClassB responsible for its own data management. When ClassA directly uses ClassB's public variables, ClassB has weak encapsulation because it exposes its internal implementation details.