Which three statements describe the object-oriented features of the Java language?



A. Objects cannot be reused.
B. A subclass can inherit from a superclass.
C. Objects can share behaviors with other objects.
D. A package must contain more than one class.
E. Object is the root class of all other objects.
F. A main method must be declared in every class.

題解

選項A,物件(object)是可以重複使用的。

選項B,子類別(class)當然可以繼承父類別(不然怎麼會有父子關係)。

選項C,物件可以和其它物件透過靜態(static)的類別方法、同樣的父類別方法或是介面(interface)方法來共享行為。

選項D,並沒有規定套件(package)一定要至少有一個類別,什麼都不放,或是放介面也是可以。

選項E,「Object」是所有類別物件的最上層。若類別沒有使用extends來指定繼承哪個類別的話,會自動繼承「Object」類別。

選項F,並沒有規定每個類別一定要有「main」方法。