1. 用abstract 修飾類時,則此類被稱之為抽象類
2. 含有抽象方法的類必須被聲明為抽象類,抽象類必須被繼承、抽象方法必須被重寫,否則子類就也要定義為抽象類及含有抽象方法,若子類繼承後沒有重寫方法,則出現錯誤 (Cat is not abstract and does not override abstract method enjoy() in Animal)
3. 抽象類不能被實例化,也就是不能以new產生新的物件,否則會出現錯誤 (Animal is abstract; cannot be instantiated)
4. 抽象方法只需被聲明,不需被實現
You can create objects of concrete subclasses.
You can still create object variables of an abstract class, but such a variable must refer to an object of a nonabstract subclass. For example:
Person p = new Student ("Vince Vu," "Economic");
Here p is a variable of the abstract type Person that refer to an instance of the nonabstract subclass Student.