Abstraction in Java?

前端 未结 10 1827
鱼传尺愫
鱼传尺愫 2021-02-15 00:43

Today i heard from my friend, that encapsulation is not only achieving information hiding but also abstraction. How does it achieve?

public class employee {

           


        
10条回答
  •  广开言路
    2021-02-15 01:10

    It seems encapsulation and abstraction has got everyone confused. If you ask me, those are poles-apart topics and there is absolutely no scope of confusion in this.

    abstraction happens when you use "abstract" keyword, and encapsulation happens when you create a class. a good implementation of encapsulation involves making all your data members private.

    I wrote a few blog posts that might help you:

    Learn how to use an Abstract Class in Object Oriented Design

    The Theory of Abstraction

提交回复
热议问题