Monday 24 October 2011

Java/J2EE interview questions: – Distinguish 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


No comments:

Post a Comment