Home » JAVA Programming » Collections » Question
  1. What is the output of this program?
    import java.util.*;
    public class Linkedlist_Example
    {
    public static void main(String args[])
    {
    LinkedList object = new LinkedList();
    object.add("O");
    object.add("V");
    object.add("E");
    object.addFirst("L");
    System.out.println(object);
    }
    }
    1. [L]
    2. [L, O]
    3. [L, O, V]
    4. [L, O, V, E]
    5. None of these
Correct Option: D

object.addFirst(“L”) method is used to add ‘L’ to the start of a LinkedList object obj.



Your comments will be displayed only after manual approval.