Encapsulation
The process of enclosing certain information. In the context of object-oriented programming, encapsulation refers to hiding irrelevant data (e.g., variables and methods) outside of a class.
# Access specifiers
Many OOP-based languages utilise access specifiers to implement encapsulation in code. The following are some examples of certain access specifiers used:
Access specifier | Visible to objects of other classes within the namespace | Visible to objects of child classes within the namespace | Visible to objects of other classes outside the namespace | Visible to objects of child classes outside the namespace |
---|---|---|---|---|
public | Yes | Yes | Yes | Yes |
private | No | No | No | No |
protected | No | Yes | No | Yes |
internal | Yes | No | No | No |
protected internal | Yes | Yes | No | No |