Computer Applications

'An object's state and behaviour are two distinct things yet linked to one another'. Comment.

Objects & Classes

13 Likes

Answer

An object's state refers to the values of its attributes or properties, while an object's behaviour refers to the actions or methods that the object can perform.

An object's state and behaviour are closely linked and can affect each other. The behaviour of an object is dependent on its current state, and changes in its behaviour can cause changes in its state.

For example, taking fan as a real-world object, a fan in OFF state might have a behaviour of switching it on. However, if the fan's state changes to ON then behaviour of switching the fan ON may no longer be applicable.

Conversely, an object's behavior can also affect its state. Fan object will have a behaviour of switching it OFF. Calling this behaviour will change the state of the fan to OFF.

Answered By

7 Likes


Related Questions