What's the difference between abstraction and encapsulation?

前端 未结 24 1106
攒了一身酷
攒了一身酷 2020-12-22 17:16

In interviews I have been asked to explain the difference between abstraction and encapsulation. My answer has been along the lines of

  • Abstraction<

24条回答
  •  旧时难觅i
    2020-12-22 17:58

    In my view encapsulation is a thought of programmer to hide the complexity of the program code by using access specifier.
    Where as Abstraction is separation of method and object according to there function and behavior. For example Car has sheets, wheels, break, headlight.

提交回复
热议问题