How do objects encapsulate state and behaviour?
Answers
Answer:
Every object has its own object scope that might hold a bunch of instance variables. ... We can say that an object encapsulates state (data, knowledge), which is private to the object, and exposes behaviour by the way of having publicly accessible methods. Objects have state (instance variables) and behaviour (methods)
Answer:
an object stores it's state in member variables and exposes its behaviour through the member methods.the member methods operate on member variables and serve as the primary mechanism to interact with the object.only the member methods which are wrapped inside the class can access the data and change its state.hence,the state and behaviour are said to be encapsulated by the object,hiding internal state and requiring all interaction to be performed through an object's methods