Encapsulation

From JholJhapata
Revision as of 17:01, 20 August 2019 by Admin (talk | contribs) (Created page with "'''Encapsulation''' is the process of wrapping the data and code under a single unit. It is the mechanism that binds together code and the data it manipulates. In a different...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Encapsulation is the process of wrapping the data and code under a single unit. It is the mechanism that binds together code and the data it manipulates. In a different way, encapsulation is a protective shield that prevents the data from being accessed by the code outside this shield.

Technically in encapsulation, the data in a class is hidden from other classes, so it is also known as data-hiding.

Why do we need Encapsulation

Implementation of Encapsulation

Encapsulation is implemented by using access specifiers, which defines the scope and visibility of a class member:

  • Public
  • Private
  • Protected
  • Internal
  • Protected internal

Public

Private

Protected

Internal

Protected internal