13.1 abstract class

Important Note: An abstract class can not be used to create objects. An abstract class may contain abstract methods that will be implemented in a specific sub-class.

  • Abstract class
    • You can not send an abstract method included in the non-abstract class. If a subclass of the abstract parent class can not implement all abstract methods, then the child class must be defined as abstract. In other words, in the non-extended abstract subclass of abstract class must implement all the abstract methods. Abstract method is non-static.
    • An abstract class is not to be initialized by the new operator. But he still can be defined constructor, the constructor call in its constructor subclass.
    • The method comprises the abstract class must be abstract. But it does not contain a definition of the abstract method of the abstract class. In this case, the class instance can not be created using the new operator, this class is used to define a new subclass of the base class.
    • Subclasses can override this method of the parent class, and defined as abstract. This is rare, but when it is the parent class method when the child class now becomes invalid is useful. This situation erupted class must be abstract.
    • Even if the parent class is a subclass of the concrete, this subclass may be abstract. For example, Object class is specific, but such a subclass GeometricObject can be abstract.
    • You can not use the new operator to create an instance from an abstract class, an abstract class it can be used as a data type. Therefore, creating a type of array element is the abstract is correct.

Guess you like

Origin www.cnblogs.com/cglib/p/11970605.html