Which package contains the LinkedList class in Java?
Which data structure does Java's LinkedList internally use?
What will be the output of the following code?
Java
import java.util.*;
public class Test {
public static void main(String[] args) {
LinkedList<Integer> list = new LinkedList<>();
list.add(10);
list.addFirst(5);
list.addLast(15);
System.out.println(list);
}
}
What is the time complexity of inserting an element at the beginning of a LinkedList?
What will happen if you try to access an element at an invalid index using get(int index)?
It throws IndexOutOfBoundsException
It removes the last element
Which of the following statements about LinkedList and ArrayList is true?
LinkedList provides faster random access than ArrayList
LinkedList consumes more memory than ArrayList
ArrayList consumes more memory than LinkedList
ArrayList is always faster than LinkedList
What will be the result of the following code?
Java
import java.util.*;
public class Test {
public static void main(String[] args) {
LinkedList<String> list = new LinkedList<>();
list.add("A");
list.add("B");
list.add("C");
list.remove("B");
System.out.println(list);
}
}
How does LinkedList differ from ArrayList when searching for an element?
LinkedList has O(1) search time, while ArrayList has O(n)
ArrayList has O(1) search time, while LinkedList has O(n)
Both have O(n) search time
LinkedList has O(log n) search time
What happens when pollFirst() is called on an empty LinkedList?
It throws NoSuchElementException
It removes the last element
It removes the first element
Which method retrieves, but does not remove, the last element of a LinkedList?
There are 10 questions to complete.
Take a part in the ongoing discussion
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4