a. House has a roof may be considered tight coupling.
b. a turnOnStrereo() may be considered cohesive.
c. House-is-a-Dwelling is considered good encapsulation.
d. House-has-a-door would be considered loose coupling.
e. a getAddress() method would not be considered cohesive.
Correct answers are (b.) and (d.). Please explain how they are correct and also the reason why others are incorrect.
Did you copy the question correctly? I believe option B that you've mentioned is incorrect. I found an old thread on the same question. You might find the answers there helpful. I personally don't like this type of questions, they are too vague for my liking
I would also reason that B is incorrect. Cohesion has to do with what responsibilities a class has.
a. is incorrect because a House logically has-a Roof. If a Roof also knew about what House it belongs to, that would be tight coupling.
b. is incorrect because a House may have a Stereo, but a House shouldn't be responsible for turning a Stereo on. A Stereo should be responsible for turning itself on.
c. is incorrect because inheritance has nothing to do with encapsulation.
d. is correct for the same reason a. is incorrect. A house needs a door. If the door needed a house, it would be tightly coupled.
e. is incorrect because a House has an address, and getting an address for a House is part of the House's responsibilities.