Java - Online Test - List - javasearch.buggybread.com


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'list' - 4 questions found


What will be the output of exceuting main method ?

public static void main(String[] args){
      List list = new ArrayList();
      list.add(1);
      list.add(2);
      list.add(3);
      System.out.println(list);
   }
Core Java
1,2,3
Order cannot be determined
compilation error
3,2,1

  collections  list  arraylist

What will be the output of this code

ArrayList list = new LinkedList();
list.add(3);
list.add(2);
list.add(1);
System.out.println(list);
Core Java
1,2,3
3,2,1
Order cannot be determined
Compilation Error

  list  collections

Which of the following collections stores its elements in insertion Order ?Core Java
HashMap
TreeMap
LinkedHashMap
LinkedMap

  linkedhashmap  collections  java  map

What will be the output upon executing main method ?

public static void main(String[] args){
      Set set = new HashSet();
      set.add(1);
      set.add(2);
      set.add(3);
      System.out.println(set);
   }
Core Java
1,2,3
Order cannot be determined
Compilation error
3,2,1

  set  hashset  collections







comments powered by Disqus