Abstract
For abstract method, the concret class must implement the body of it.
For example if we have Animal
and Canine
is abstract. Then Dog
must implement all the abstract methods from both these class
Note: if Canine
is abstract then it could implement the abstract method from Animal
. If that happens, Dog
doesn't need to implement anything.
Note: abstract method cannot be private.
When to use Abstract class, when to use Interface
Use:
- abstract class if you want to emphasize what the object is.
- interface if you want to emphasize what the object can do
For example, interface does not say that "wewewowo is the type of dog that can fly" but more like "this thing can fly"