Java Collections interview questions
Java Collections interview questions Q. 1. Difference Between List and Set in Java - **List**: - Ordered collection that allows duplicate elements. - Examples: `ArrayList`, `LinkedList`. - **Set**: - Unordered collection that does not allow duplicate elements. - Examples: `HashSet`, `TreeSet`. Q. 2. Difference Between Collection and Collections in Java - **Collection**: - The root interface in the Java Collections Framework. - Provides methods to add, remove, and query elements. - **Collections**: - A utility class that provides static methods to operate on or return collections, such as sorting and searching. Q. 3. Difference Between Array and ArrayList in Java - **Array**: - Fixed size, can store primitives and objects. - Faster access and more memory efficient. - **ArrayList**: - Resizable array, can only store objects. - Provides more functionality like dynamic resizing a...