This series is the Java lessons from July to August for the internship interview ~
abstract classes and Interfaces
is Java
2 mechanisms for defining abstract concepts.
Abstract class
A class does not have enough information to describe a specific object and requires other specific classes to support it.
Abstract class embodies the data abstraction of four small, is a mechanism to implement polymorphism.
It defines a set of abstract methods that are implemented by a derived class for the specific representation of this set of abstract methods. At the same time, abstract classes provide the concept of inheritance, the starting point is to inherit , otherwise it does not exist any meaning. Therefore, the definition of the abstract class must be used to inherit, at the same time in an abstract class as a node of the inheritance relationship hierarchy chain, the leaf node must be a specific implementation class.
1, abstract class can not be instantiated, the work of the instantiation should be left to its subclasses to complete, it only need to have a reference.
2. Abstract methods must be overridden by subclasses.
3. As long as an abstract class containing an abstract method, the method must be defined as an abstract class, whether or not there are other methods included.
4, the abstract class can contain specific methods, of course, can not contain abstract methods.
5. Abstract methods in subclasses cannot have the same name as the abstract methods of the parent class.
6. Abstract cannot be modified in the same class as final. (Abstract & Static is a bug in the Java language a final class can ' t be extended, an abstract class needs to be extended In order to be instantiated. Therefore, a final abstract class would be a logical contradiction.)
Java Review notes abstract classes and interfaces