SOFTWARE ENGINEERING

SOFTWARE DESIGN

DESIGN PATTERNS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which statement is correct regarding the State pattern?
A
Allows an object to alter its behaviour when its internal state changes
B
Allows (a group of) objects to be notified when some state changes
C
Changes the interface of one or more classes.
D
Simplifies the interface of a group of classes.
Explanation: 

Detailed explanation-1: -In State pattern a class behavior changes based on its state. This type of design pattern comes under behavior pattern. In State pattern, we create objects which represent various states and a context object whose behavior varies as its state object changes.

Detailed explanation-2: -The State pattern allows an object to change its behavior when its internal state changes. This pattern can be observed in a vending machine.

There is 1 question to complete.