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


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'Hashset' - 6 questions found


In what order the elements of a HashSet are retrieved ?Core Java
Random Order
Insertion Order
Natural Sorting Order
Inverse Natural Sorting Order

  collections  set  hashset  java

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

If we add Enum constants to a sorted collection ( Treemap , TreeSet ), What will be the order in which they will be maintained ?Core Java
Sorted Collection wont maintain them in any order.
Insertion Order
Order in which constants are declared.
Natural Sorting Order.

  enum  collections  sorted collections  treemap  treeset  compareTo  comparable  java

enums are intrinsically ..Core Java
private
public
static
final

  java  enum

Enums cannot be declared ..Core Java
private
public
static
final

  java  enum

Which of following stores its elements in natural Sorting Order ?Core Java
AbstractSet
HashSet
LinkedHashSet
TreeSet

  set  collections







comments powered by Disqus