Designing Software with Design Patterns - Quiz Explanation

The answers you selected are indicated below, along with text that explains the correct answers.
 
1. Which of the following is a basic principle of programming with design patterns?
Please select the best answer.
  A. Profile an application before deciding which methods to optimize
  B. Ensure that no more than one instance of a class exists at the same time
  C. Program to an interface, not an implementation
  D. Make attributes private, and provide access to them through public methods
  The corrrect answer is C. B is the intent of the Singleton pattern. A, C, and D are sound programming principles, however, C is the only principle specifically associated with design patterns.

2. Which of the following is a basic principle of programming with design patterns?
Please select the best answer.
  A. Use data encapsulation to enforce constraints on object data
  B. Programmer time is often more critical than execution time
  C. When possible, use object composition instead of inheritance
  D. Operator overloading tends to be confusing except for essentially numeric objects
  The correct answer is C. When possible use object composition instead of inheritance, is the principle most closely associated with design patterns.

3. Design patterns can be used in a single class or programs when:
Please select the best answer.
  A. Classes and objects need to maintain patterns
  B. Classes and objects need to form patterns
  C. When classes and objects have roles as participants in a pattern
  D. Classes and objects have more than one role
  The correct answer is D. Design patterns can be used in a single class or programs when classes and objects have more than one role. Combining design patterns works well with classes and objects that have multiple roles, rather than only one role.