Computer Applications
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.
Related Questions
The class that gets inherited is known as …………… .
- Parent class
- Base class
- Super class
- All of these
When many sub classes are inherited from a single base class, it is known as …………… .
- Hierarchical inheritance
- Multiple inheritance
- Single inheritance
- Multilevel inheritance
Name the access specifiers available in Java.
Explain visibility in terms of the following access modifiers:
- public
- private
- protected
- no modifier specified