Java/J2EE interview questions: – What is difference between State and Strategy pattern?

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s