a class implements a interface is saying that: "i can do everything wrote in this interface, use me if you want these methods to be done" if a class exneds a abstract class, it is saying that: "i have all things in this class",but not meaning you can trust it to do what the base class can do
另外一个例子就是人类的飞行器——因为一个金属筒原本不会飞的。在加上可以飞的观念的同时在飞行器上加上Flayable的函数实现体——也就是发动机、翅膀、流体力学的应用等。接口 抽象的区别:
接口和抽象都没有函数体(仅有声明),因为没有办法确定所要实现的实例究竟以什么方式“飞”。对于抽象:可以想象抽象类下边的类都具有的能力(但不知道具体的实现过程)一般是用接口来实现,比如对“会飞的生物类”来说,对于继承它的子类肯定可以飞,但它们飞的时候肯定又不一样,是千姿百态的就没有办法确定“飞”的函数体,就如老鹰(Eagle)和蝴蝶(Butterfly)。它们需要在自己的类中添加“飞”的函数体。而对于交通工具,“飞”并不是必须实现的一个功能,所以引入“可以飞”(Flyable)这样一个接口就可以了,但“飞”的函数体还是得自己实现。
if a class exneds a abstract class, it is saying that: "i have all things in this class",but not meaning you can trust it to do what the base class can do