Interface (interface)
1.interface create an interface, implements implement interface
Interface jiekou{}
Class lie implements jiekou{}
2. Interfaces can have attributes, but must be assigned, not recommended in Interface definition properties (can be used to define constants)
3. Interface, you can define a method with the same name as the interface
4. All methods of the interface have no method body
Interface jiekou{void A ();}
5. The permission decoration of the method defined by the interface is public by default, and when the class implementing the interface overrides its method, the declaration public adornment must be displayed;
6. The class that implements the interface must implement all the methods defined within the interface, except for the abstract class, and the non-abstract subclasses of the abstract class must implement
7. A class can implement multiple interfaces, separated by a comma (,) between the interface name and the interface name
8. Interfaces can inherit interfaces, homogeneous inheritance, using the extends keyword.
9. The meaning of an interface is to define a set of standards or specifications.
Abstract class
1. Defining abstract Classes: Public abstract class helloworld{}
2. Define abstract methods: Abstract void func ();
3. Abstract methods must be placed in abstract classes, but abstract classes do not necessarily define abstract methods.
4. Ordinary methods can be defined in abstract classes;
5. Abstract classes cannot be instantiated, but can create references to abstract types that must point to their non-abstract subclasses: Parent a =new son ();
6. There is no method body for abstract methods;
7. Inheriting a non-abstract subclass of an abstract class, you must override any methods that are not implemented by the abstract parent class.
Java Learning Notes interfaces and abstract classes