Is OOP & completely avoiding implementation inheritance possible?

前端 未结 8 2305
故里飘歌
故里飘歌 2020-12-15 05:34

I will choose Java as an example, most people know it, though every other OO language was working as well.

Java, like many other languages, has interface inheritance

8条回答
  •  醉酒成梦
    2020-12-15 05:38

    Inheritance is not necessary for an object oriented language.

    Consider Javascript, which is even more object-oriented than Java, arguably. There are no classes, just objects. Code is reused by adding existing methods to an object. A Javascript object is essentially a map of names to functions (and data), where the initial contents of the map is established by a prototype, and new entries can be added to a given instance on the fly.

提交回复
热议问题