Java Collections Framework Interview Questions

    Question 1JAVA - Collection Interface

    Which of the following is the root interface of the Java Collections Framework?

    Question 2JAVA - List Characteristics

    Which statement about `List` is correct?

    Question 3JAVA - Set Characteristics

    Which statement about `Set` is true?

    Question 4JAVA - Map Basics

    Which statement is correct about `Map`?

    Question 5JAVA - ArrayList Example

    What will this code print?

    import java.util.*; class Test { public static void main(String[] args) { List<String> list = new ArrayList<>(); list.add("A"); list.add("B"); list.add("A"); System.out.println(list); } }

    Question 6JAVA - HashSet Example

    What will this code print?

    import java.util.*; class Test { public static void main(String[] args) { Set<Integer> set = new HashSet<>(); set.add(1); set.add(2); set.add(1); System.out.println(set); } }

    Question 7JAVA - HashMap Example

    What will this code print?

    import java.util.*; class Test { public static void main(String[] args) { Map<Integer, String> map = new HashMap<>(); map.put(1, "Java"); map.put(2, "Python"); map.put(1, "C++"); System.out.println(map); } }

    Question 8JAVA - Iterator

    Which method of `Iterator` is used to remove an element during iteration?

    Question 9JAVA - Fail-Fast Iterator

    Which collections use fail-fast iterators?

    Question 10JAVA - Queue Interface

    Which method of `Queue` retrieves and removes the head of the queue, or returns `null` if empty?