Abstract class abstract method

Abstract: Use abstract modification method, there is no method body, only a statement.

Abstract class: abstract class is a class that contains abstract methods, through abstract class, we can do the design restricted subclass of the more general between subclasses

Use points: 1. abstract class defines the functions of the method is an abstract class

2. An abstract class can not be instantiated, it can not be used to instantiate new abstract class

3. An abstract class may contain attributes, methods, construction method. The method can not be used but new configuration example, calls can only be used by subclasses

4. An abstract class can only be inherited

The subclass must implement the abstract methods

  

Interface than "abstract class" also abstract abstract class, subclass can be more standardized restrained. Interface does not provide any implementation, the interface all methods are abstract methods. Defines only the interface specification does not define specific implementations.

Statement format: access modifiers interface [extends parent interface 1, parent interface 2] {

Constants defined;

The method defined;

}

A detailed description of the definition of the interface: 1 access modifier: only pulic or default

2. Interface name: class name and use the same naming scheme

3.extends: interface multiple inheritance

4. Constant: interface attributes can only be a constant, modified with static static final

5. Methods: The interface is only public abstract

 

Highlights:

 

Guess you like

Origin www.cnblogs.com/laurarararararara/p/11365213.html