Java/J2EE interview questions: – Differences between State and Strategy pattern?

Published on by javainterviewseries

This is one of the most asked JAVA/J2EE interview questions. So one can differentiate this design pattern and answer this as follows: -

Strategy State
Family of algorithms is interchangeable which means that every algorithm does the same thing but in different way. States are not interchangeable.
Encapsulate each algorithm into a class. We encapsulate each state into a class in state pattern.
Descendants should prepared for most possible events. Can only process a few events according to the state machine model.
Concrete strategies usually don’t know the others. Usually concrete states know other concrete states.
More dynamic modeling. More static modeling.

Also see the following video on Buider Design Pattern for the preparation of JAVA/J2EE interview questions: -

Visit for Java/J2EE interview questions

Regards,

Visit for more author's other blogs on Java/J2EE interview questions

To be informed of the latest articles, subscribe:

Comment on this post