Abstract class of Java
With the definition of new subclasses in the inheritance hierarchy, the class becomes more and more specific, while the parent class is more general and general. Class design should ensure that parent and child classes can share features. Sometimes a parent class is designed so abstract that it has no concrete instance. Such a class is called an abstract class.
1. When you modify a class with abstact, it is called an abstract class;
2. When a method is modified with abstract, it is called abstract method: abstract method has only method declaration and no method implementation, and ends with semicolon;
3. Classes containing abstract methods must be declared as abstract classes;
4. The abstract class cannot be instantiated. The abstract class is used to be inherited. The subclass of the abstract class must override the abstract method of the parent class and provide the method body. If you do not override all abstract methods, it is still an abstract class;
5. Abstact cannot be used to modify attributes, private methods, constructors, static methods and final methods;
6. An abstract class can have a constructor, but you cannot directly create an instance object of the abstract class in the constructor;
Animal. java
Test. java
Output:
Dogs move by running