Abstract Method: An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon).
For example:
abstract void moveTo(double variable, double variable2);
抽象方法就是;定义一个方法但是不去实现它,并且使用 abstract 关键词来修饰。
Abstract Class: it is a class that is declared abstract - it may or may not include abstract methods. Abstract classes can not be instantiated, but they can be inherited.
抽象类: 使用abstract 关键字修饰的类, 可以含有抽象方法但是也可以不含有抽象方法. 但是一定不能被实例化,可以被继承
for example:
public abstract class GraphicObject {
// declare fields
// declare nonabstract methods
abstract void draw();
}
Note: 当一个抽象类被继承的时候, 继承它的子类可以有两种状态: 1. 完全实现父类中的抽象方法, 这种情况下子类就是正常的类. 2. 没有完全实现父类中的抽象方法,这种情况子类必须被定义成Abstract !