Simple way to understand Encapsulation and Abstraction

后端 未结 15 1142
谎友^
谎友^ 2020-11-27 09:47

Learning OOP concepts especially interested to understand Abstraction and Encapsulation in depth.

Checked out the below already

Abstraction VS Information Hi

15条回答
  •  一生所求
    2020-11-27 10:47

    Abstraction is Showing necessary info to the user where as Encapsulation hide the unwanted data from the user(Product from the user).

    Encapsulation Implements the Abstraction.

    Abstraction is the process where as Encapsulation actually implements it. For Eg. Adding user logic -> we need to validate the user , creating DB connection and insert the User. So user do not know fist need to call validate function , creating DB connection and then insert the Value in DB. He only call the AddUser function which call the internally all logic with in , this is only Encapsulation (Grouping the feature and hiding the methods).

提交回复
热议问题