KnowledgeBoat Logo

Computer Applications

What do you understand by the phrase, "Objects encapsulate state and behaviour"?

OOP Intro Java

47 Likes

Answer

An object stores its 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 the methods of the object.

Answered By

28 Likes


Related Questions