What is the primary advantage of using a generic List (e.g., List<String>) in Java?
List
List<String>
Which of the following is an interface in Java that represents an ordered collection of elements, allowing duplicate values?
What will be the output of the following code snippet?
List<String> colors = new ArrayList<>();colors.add("Red");colors.add("Green");colors.add("Blue");colors.remove(1);System.out.println(colors);
Which of the following operations is generally more efficient in an ArrayList compared to a LinkedList?
ArrayList
LinkedList
Which of the following is the correct way to check if a Java List is empty?
What is the purpose of the ListIterator interface in Java's Collections Framework?
ListIterator
Which of the following methods can be used to remove all elements from a Java List?
Which of the following operations is generally more efficient in a LinkedList compared to an ArrayList?
What is the primary difference in the underlying data structure between ArrayList and LinkedList?
Which of the following are common implementations of the List interface in Java?
What will be the state of the numbers list after executing the following code?
numbers
List<Integer> numbers = new ArrayList<>();numbers.add(1);numbers.add(2);numbers.add(3);numbers.subList(0, 2).clear();System.out.println(numbers);
Which List method is used to replace the element at a specific index with a new element?
Which List method returns the number of elements in the list?
Consider the following code snippet:
List<String> items = Arrays.asList("apple", "banana", "cherry");items.set(1, "grape");System.out.println(items);
What will be the output of this code?
Which of the following statements is true about the indexOf() method of the List interface?
indexOf()