Question: Question: What is the primary function of the strategy pattern in Java? A ) To represent a one-to-many dependency between objects, helping to notify dependents

Question: What is the primary function of the "strategy pattern" in Java?
A ) To represent a one-to-many dependency between objects, helping to notify dependents of state changes.
B ) To encapsulate algorithms within a class, allowing for dynamic selection of an algorithm at runtime.
C ) To ensure that a class has only one instance and provides a global point of access to that instance.
D ) To define a common interface for a family of related objects and encapsulate their creation.


Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below The correct option is B To encapsulate ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!

Q:

\f