Question
import java.util.*;
class Linkedlist {
public static void main(String args[]) {
LinkedList obj = new LinkedList();
obj.add("A");
obj.add("B");
obj.add("C");
obj.addFirst("D");
System.out.println(obj);
}
}
What is the output of this program?
import java.util.*;
class Linkedlist {
public static void main(String args[]) {
LinkedList obj = new LinkedList();
obj.add("A");
obj.add("B");
obj.add("C");
obj.addFirst("D");
System.out.println(obj);
}
}
Answer: Option D
Was this answer helpful ?
obj.addFirst("D") method is used to add 'D' to the start of a LinkedList object obj.
Output:
$ javac Linkedlist.java
$ java Linkedlist
[D, A, B, C]
Was this answer helpful ?
More Questions on This Topic :
Question 7.
Which of these methods must be made static?
....
Submit Solution