Computer Applications

How does a class encapsulate state and behaviour?

Encapsulation & Inheritance in Java

9 Likes

Answer

A class encapsulates state and behavior by combining data and functions into a single unit. The state of an object is represented by its member variables and behaviour is represented by member methods. By combining state and behavior within a single unit, the class encapsulates the implementation details, allowing the outside world to interact with the object through a well-defined interface.

Answered By

6 Likes


Related Questions