Differences and relations between abstract classes and interfaces.

the difference:

① Keywords:

Keywords abstract class abstract class

Interface interface

② subclass implementation:

Abstract class subclass inherits keyword extends

Interface Subclass achieved by keyword implements.

③ constructor:

In the presence of an abstract class constructor

No interface constructor

④ properties and methods:

Abstract class attributes may be present in general, you may also have the general procedure.

Interface methods are public abstract modified abstract method, interface properties are modified static public static final constants.

⑤ Features:

An abstract class features single inheritance, multiple inheritance

Interface features: multiple inheritance, multiple implementation, multiple inheritance.

contact:

① interface is a particular abstract class, an abstract class which are all abstract methods.

② can not create an object, the object must be created by a subclass.

Summary: The generic interface for the same functions as different declarations essence of things. The abstract class is used to declare the same thing essentially the same function.

Guess you like

Origin www.cnblogs.com/myxc-19/p/11870000.html