Abstract class
Abstract class must be abstract
modified, subclasses must implement the abstract methods abstract class, if there is not achieved, then the subclass must also be modified by abstract. Abstract class default permissions for the modifier public
can be defined as a public or procted, if defined as private, then the subclass can not inherit. An abstract class can not create object
The difference between abstract classes and ordinary classes
- Abstract class must be public, procted modification (if private modification, then the subclass can not inherit, it can not achieve its abstract method). The default is public by default
- An abstract class can not create object
- If a subclass inherits an abstract class, it must implement all its abstract methods. If there is an abstract method is not implemented, then it must be defined as abstract
interface
Using implicit variable interface public static final
modification, and needs to be given an initial value. Implicit method of using public static
a modified (and can only be public, if it is private, procted, then compile error). The method can not have a default interface specific implementations (JDK1.8 can start with a default implementation)
The difference between abstract classes and interfaces
- Abstract classes can inherit only once, but can implement multiple interfaces
- Interfaces and abstract classes must implement all the methods in which, if an abstract class abstract method is not implemented, then the need to define a subclass of abstract class. You can have non-abstract methods abstract class
- Interface with public static final variables must be modified, and the need to give the initial values. Therefore, the implementation class can not be redefined, not change its value.
- The default interface methods are public abstract, can only be of this type. Can not be static, the method does not allow interface override subclass, the abstract class allows static methods