This piece of writing is reprinted from the following URL:
Http://download.oracle.com/javase/tutorial/java/IandI/abstract.html
Just for the use of Self Learning.
AnAbstract classIs a class that is declaredabstract-It may or may not include abstract methods.
AnAbstract MethodIs a method that is declared without an implementation (without braces, and followed by a semicolon)
If a class includes des abstract methods, the class itselfMustBe declaredabstract
When an abstract class is subclassed, The subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, the subclass must also be declaredabstract.
Note:All of the methods inInterfaceAreImplicitlyAbstract, soabstractModifier is not used with interface methods (it cocould be-it's just not necessary ).
Unlike interfaces, abstract classes can contain fields that are notstaticAndfinal, And they can contain implemented methods. Such abstract classes are similar to interfaces, doesn't that they provide a partial implementation, leaving
It To subclasses to complete the implementation. If an abstract class containsOnlyAbstract method declarations, it shoshould be declared as an interface instead.
By comparison, abstract classes are most commonly subclassed to share pieces of implementation. A single abstract class is subclassed by similar classes that have a lot in common (the implemented parts of the abstract class), but also have some differences
(The abstract methods ).
An abstract class may havestaticFields andstaticMethods. You can use these static members with a class reference-for example,
AbstractClass.staticMethod()-As you woshould with any other class.