InterviewSolution
| 1. |
Why Map Interface Does Not Extend Collection Interface? |
|
Answer» A good answer to this interview question is “because they are INCOMPATIBLE“. COLLECTION has a method add(Object o). Map can not have such method because it need key-value pair. There are other reasons also such as Map SUPPORTS keySet, valueSet etc. Collection classes does not have such VIEWS. Due to such big differences, Collection interface was not used in Map interface, and it was build in separate HIERARCHY. A good answer to this interview question is “because they are incompatible“. Collection has a method add(Object o). Map can not have such method because it need key-value pair. There are other reasons also such as Map supports keySet, valueSet etc. Collection classes does not have such views. Due to such big differences, Collection interface was not used in Map interface, and it was build in separate hierarchy. |
|