Core Java Interview Questions – Collection Framework
This Core Java Interview Questions-Collection Framework providing all the interview questions including what is the collection, static memory, dynamic memory, the need for collection, Collection interfaces, Ordered collections and Unordered collections, Collections allow duplicates and much more.
What is a dynamic memory in java?
The memory is not Fixed. Size increase when we add elements and decrease when we remove elements.
Examples of dynamic objects in java application?
What is Collection Framework?
To structure the data, a number of algorithms were proposed called Data structures and Algorithms.
Implementation of these algorithms is called Collection FrameWork.
What is the linear collection?
In the linear data structure, elements connected properly one to one.
Examples, array, stack, queue, linked list…
What is a non-linear collection?
In the non-linear collection, elements connected randomly, example trees and graphs.
What type of elements can be stored into Collection object?
Only objects(Primitives not allowed).
Can we store a primitive type forcefully into collection object?
No, primitive type implicitly converts into Object using auto-boxing concept(since jdk1.5).
What is Abstract data type in Collection Framework?
Generally, Data structure algorithm can be specified as an abstract type(interface) programmatically.
What is Enhanced for loop?
for-each loop is called enhanced for loop
It is since JDK 1.5
It is used to process the elements of Array and Collection.
What are the disadvantages of the for-each loop?
Process element by element and only in forward direction.
What kind of elements Array can hold?
An array holds only Homogeneous data elements.
An array can hold both Primitives and Object type elements.
Give some examples of Ordered collections?
What is Autoboxing?
Converting primitive data into Object implicitly is called AutoBoxing.
AutoBoxing is since JDK 1.5.
What type of Collection doesn’t allow duplicates?
Set collection implementations like…
What is Generics?
Used to set restrictions on what type of data is allowed to store in the Collection object.
Much working like templates concept in C++
Generics introduced in JDK 1.5