Is there any relation between the class that implements interface and that interface?

后端 未结 8 832
有刺的猬
有刺的猬 2020-12-19 16:56

Consider this class hierarchy:

  • Book extends Goods
  • Book implements Taxable

As we know, there is a relationship

8条回答
  •  甜味超标
    2020-12-19 17:19

    When we say one class extends another class it is having strong relation ship known as 'inheritance'.this means when one child extends parent then child should be able to inherit something from parent class like horse IS A animal .Horse is inheriting some properties of animal .But when a class implements another class then child class is trying to implement a contract dosen't need to inherit anything from parent just following a contract ,that why interface all methods are abstract by default but you can provide some concrete method in class(for child class to inherit) and can make some of then abstract is well .

    So for me extends is inheritance and interface in implementing contract.hope this is satisfactory

提交回复
热议问题