This is the only question about interfaces in oop I can't seem to fully explain. So again, why in oop can a class implement multiple interfaces?
If you can provide a few examples that would be great. thanks in advance.
Conceptual Example
The way I think about the multiple interfaces is interface is like the verb or adjective, and class is like the subject.
A tiger can run, so the Tiger class
may implement Runnable Interface
.
A tiger can eat, so the Tiger class
may implement Eatable Interface
.
Because an instance of the class could have different behaviors, we could have different corresponding interfaces.
Realistic Example
java.util Class HashMap<K,V>
It implements Serializable, Cloneable, Map<K,V>
All of the interfaces are the characteristics of Class HashMap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With