在abstract class方式中,Demo可以有自己的数据成员,也可以有非abstarct的成员方法,而在interface方式的实现中,Demo只能够有静态的不能被修改的数据成员(也就是必须是static final的,不过在interface中一般不定义数据成员),所有的成员方法都是abstract的。从某种意义上说,interface是一种特殊形式的abstract class。

解决方案 »

  1.   

    接口可以实现多重继承
    class A implements interface001,interface002,interface003
    {
        ......
    }
    ★★ 签名 ★
    ================================================================
    我不能随波浮沉
      为了我挚爱的亲人
        再苦再累也要坚强
          只为那些期待眼神···
      

  2.   

    没有不同,但是你extends了该抽象类以后就不可以再extends其他的类了,而
    如果这是个接口,你implements了它以后还可以extends其他的类.谢谢
      

  3.   

    也就是说,除了implements和extends,二者没有其他的不同了,在内存中应该是一样的,对吧
      

  4.   

    The most important difference between abstract class and interface is what they are trying to describe.The class is to show : what is it.
    It's trying to describe the attributes of objects.but the interface is to demonstrate : what can it do.
    It's trying to describe the functions of objects.I suggest you to look some books about UML,
    they will give you more useful information about such difference.In coding,
    The interface can implements multi-inheritance.
    The abstract class can have attributes.
      

  5.   


    You’ll learn that the interface is more than just an abstract class taken to the extreme, since it allows you to perform a variation on C++’s “multiple inheritance,” by creating a class that can be upcast to more than one base type. Keep in mind that the core reason for interfaces is shown in the above example: to be able to upcast to more than one base type. However, a second reason for using interfaces is the same as using an abstract base class: to prevent the client programmer from making an object of this class and to establish that it is only an interface. This brings up a question: Should you use an interface or an abstract class? An interface gives you the benefits of an abstract class and the benefits of an interface, so if it’s possible to create your base class without any method definitions or member variables you should always prefer interfaces to abstract classes. In fact, if you know something is going to be a base class, your first choice should be to make it an interface, and only if you’re forced to have method definitions or member variables should you change to an abstract class, or if necessary a concrete class.