हिंदी

Introduction to Encapsulation

Advertisements

Topics

Introduction to Encapsulation:

Encapsulation, the process of wrapping data and functions together as a unit, can be made possible by declaring the class members private. Once a member method or a member datatype is declared private, it can only be accessed within the class. 

Data Hiding 

Encapsulation supports data hiding by restricting access to class data members. Private data members are only accessible within their class, ensuring they cannot be used in other classes or the main class, promoting secure data management.  

Access Specifier 

This defines the visibility of a class method or data.  

  1. Private: Private members are accessed only within the scope of a class. 
  1. Public: Public members can also be accessed outside the class visibility. 
  1. Protected: Protected members are used simply as private members within the class in which they exist but can be accessed to derived class (during inheritance). 
If you would like to contribute notes or other learning material, please submit them using the button below.
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×