Difference between abstraction and encapsulation?

This is indeed the most asked question in object oriented world. After sometime i came to final conclusion and now i am able to define these 2 concepts precisely

1- Abstraction: Abstraction allows you to focus on what the object does, instead of going into its implementation details

For example:
var string = 5;
int number = convert.toint32(string);

Now you know that using convert.toint32 method, you can convert string to int, you know what this object does, but at the same time you don't know its implementation details. Implementation details of this object is hidden from the user, this is abstraction.

2- Encapsulation: It means hiding the implementation or internal details of how object does something.

For example:
if you look at the abstraction example, convert.toint32 implementation is hidden from outside world. This is very simple example of encapsulation.

Comments

Popular posts from this blog

GRANDING UTime Master - IDOR (CVE-2023-45393)

GRANDING UTime Master - Stored XSS (CVE-2023-45391)

Ericsson BSCS iX R18 Billing & Rating (ADMX, MX) - Stored XSS (CVE-2020-29144, CVE-2020-29145)