Which two are true? (Choose two.)

  1. An encapsulated, public class promotes re-use.

  2. Classes that share the same interface are always tightly

  3. An encapsulated class allows subclasses to overload methods, but

  4. An encapsulated class allows a programmer to change an


Correct Option: A,D

AI Explanation

To answer this question, let's go through each option:

Option A) An encapsulated, public class promotes re-use - This option is true. Encapsulation is a concept in object-oriented programming that promotes re-usability by hiding the internal implementation details of a class and exposing only the necessary public methods or properties. By encapsulating a class, other developers can use the class without needing to know the intricate details of how it works, thus promoting re-use.

Option B) Classes that share the same interface are always tightly - This option is false. Classes that share the same interface may or may not be tightly coupled. The level of coupling between classes depends on how they interact with each other and the dependencies they have. It is possible to have loosely coupled classes that share the same interface.

Option C) An encapsulated class allows subclasses to overload methods, but - This option is false. Encapsulation is a mechanism that hides the internal implementation details of a class. Overloading methods is a concept related to polymorphism, where a class can have multiple methods with the same name but different parameters. Encapsulation and method overloading are separate concepts.

Option D) An encapsulated class allows a programmer to change an - This option is true. Encapsulation provides a level of abstraction and encapsulates the internal implementation details of a class. This allows a programmer to change the internal implementation of a class without affecting the code that uses the class. The external code only interacts with the public methods or properties of the encapsulated class, so changes to the internal implementation can be made without impacting the code that uses the class.

Based on the explanations above, the correct options are A) An encapsulated, public class promotes re-use and D) An encapsulated class allows a programmer to change an.

Find more quizzes: