Please see my other Web Development articles.
Knowing How to Leverage Abstractions
|Implementation details:||Some members (methods).||No.|
|Inherit from:||Abstract class, interface||Interface only.|
|Members can have access modifiers:||Yes.
Abstract members private by default.
Interface members public by default.
Implementation Details: Abstract Classes
As illustrated in the next example, the abstract Employee class may define a constructor method for initializing some of its data.
As specified in the table above, no implementation details are allowed within interfaces.
Field: Abstract Classes
As illustrated in the previous example, the abstract Employee class may contain some field for data storage.
As specified in the table above, no fields are allowed within interfaces.
Abstract classes may inherit other abstract classes or interfaces whereas an interface may only inherit another interface.
Members with Access Modifiers
As illustrated in the previous example, the abstract Employee class may use access modifiers (default: private), but interfaces may not (default: public).