Sol: Yes but it’s not a part of framework but now if we are talk about that classes and API which was design before collection framework to achieve data structure functionality we call it legacy classes, legacy API Vector, HashTable and many more classes and interfaces in legacy collection.
Sol: Yes.
Sol: Collection means grouping or gathering of Objects here we are grouping an elements called Objects.
Element can be homogeneous and heterogeneous. It’s a literal meaning of collection but in coding point of view Collection is an interface, to achieve functionality of Collection Framework Java given many API’s under java.util package.
Inside this package one API is a collection: Collection, Collections, Set, List, Queue, Map depending on the behavior and memory management collection are categorized.
Some collection where duplicity is allowed but some not, some Collection Store elements in key and value form but some not, some maintaining indexing some not.
So in different parts collection is categorized and for this hierarchy is maintained.
And the classes and interface related to collection framework are in java.util package and there is hierarchy, in hierarchy the root interface is a collection interface.
Sol: We perform collection of an object because on object we can perform common operation (Sorting, Searching) whenever in programming if we have lots of data and perform common operation on that data so we gather those data at common place.
Framework Means: Framework means set of an API, API which works on predefine algorithm and targeted to the specific domain.
In any Framework API‘s fixed algorithm fixed and target is fixed Algorithm is tested we need not to test it.
Framework benefits: Maintenance Easy, guaranteed no wrong output.
Sol: API is mandatory without API we can’t imagine for any language but framework is an optional.
Map is part of collection framework but not a collection because it’s not inheriting the Collection
Sol:
Here interviewer trying to confuse you that you said string is immutable once it assigne can’t change but here is concatenating is happening here so you should say here 1 reference is created for “hi” and after that 2 refernce is created for “hello” and finally 3 refernce is created for “hihello” so initially s is pointing to 1 after that its pointing to 3 reference location.
Sol: Concat method is applicable for only concating string type data. But using “+” operator you can use any kind of data to concat the string.
Internally how “+” works:
Sol: codersarts