Abstract classes are usually meant to share pieces of implementation and to be extended:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
public abstract class Employee { protected String position; protected int experience; private String name; // non-abstract methods (same implementation for all descendant classes) public String getName() { return name; } // abstract methods (to be implemented -differently- by descendant classes) abstract void getSalary(); } |
Abstract methods are methods declared without an implementation (no body and semicolon at the end).
1 2 3 |
abstract void getSalary(); |
An important thing to remember about abstract methods is that if a class has one or more abstract methods then ..Continue Reading