Java List Interface

Here are 10 essential multiple-choice questions on Java List Interface, covering key concepts.


Last Updated :
Discuss
Comments

Question 1

Which of the following classes does NOT implement the List interface?

  • ArrayList

  • LinkedList

  • HashSet


  • Vector

Question 2

What is the default initial capacity of an ArrayList when created with a no-arg constructor?

  • 5

  • 10

  • 16

  • 0

Question 3

What will be the output of the following code?

Java
import java.util.*; public class Test {     public static void main(String[] args) {         List<Integer> list = new ArrayList<>();         list.add(1); list.add(2); list.add(3);         list.add(1, 10);         System.out.println(list);     } } 


  • [1, 2, 3, 10]

  • [1, 10, 2, 3]

  • Compilation Error

  • Runtime Error

Question 4

Which List implementation provides the best performance for random access operations?

  • LinkedList

  • ArrayList

  • Vector

  • Stack

Question 5

Which of the following statements is true about LinkedList?

  • It uses an array internally for storage

  • It allows fast random access using indexing

  • It has efficient insertions and deletions at both ends

  • It does not support null values

Question 6

What will be the output of the following code?

Java
import java.util.*; public class Test {     public static void main(String[] args) {         List<Integer> list = new LinkedList<>();         list.add(10);         list.add(20);         list.remove(0);         System.out.println(list);     } } 


  • [10]

  • [20]


  • Compilation Error


  • Runtime Error

Question 7

What is the time complexity of ArrayList.add(index, element) operation in the worst case?


  • O(1)

  • O(log n)

  • O(n)

  • O(n log n)

Question 8

Which of the following List implementations is synchronized?


  • ArrayList


  • Vector

  • LinkedList


  • CopyOnWriteArrayList


Question 9

Which method is used to obtain a sublist from an existing List?

  • list.getSubset(start, end)

  • list.extract(start, end)

  • list.subList(start, end)

  • list.split(start, end)

Question 10

What will be the output of the following code?

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


  • [A, B, C, D]


  • [A, B, C]

  • Compilation Error

  • Runtime Error

There are 10 questions to complete.

Take a part in the ongoing discussion