To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) An encapsulated, public class promotes re-use - This option is true. Encapsulation refers to the practice of hiding internal implementation details of a class and providing a public interface for interacting with the class. By encapsulating the internal details, the class becomes more modular and can be easily reused in different parts of a program.
Option B) Classes that share the same interface are always tightly encapsulated - This option is incorrect. Two classes that share the same interface may or may not be tightly encapsulated. Encapsulation is about hiding implementation details, while an interface defines a contract for interacting with a class. It is possible for multiple classes to implement the same interface but have different levels of encapsulation.
Option C) An encapsulated class allows subclasses to overload methods, but does NOT allow overriding methods - This option is incorrect. Encapsulation does not restrict the ability to override methods. Overloading refers to defining multiple methods with the same name but different parameters, while overriding refers to redefining a method in a subclass with the same name and parameters as the method in the superclass. Encapsulation is unrelated to these concepts.
Option D) An encapsulated class allows a programmer to change an implementation without affecting outside code - This option is true. Encapsulation allows the internal implementation details of a class to be hidden from outside code. This means that the class can be modified or refactored internally without affecting the code that interacts with the class. As long as the public interface remains the same, the outside code will not be affected.
The correct answers are A) An encapsulated, public class promotes re-use and D) An encapsulated class allows a programmer to change an implementation without affecting outside code. These options are true because encapsulation promotes reusability and allows for changes in implementation without affecting the code that interacts with the class.