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


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'collections' - 24 questions found


Which of the following collection maintain its elements in Natural Sorted order ? Core Java
HashMap
TreeMap
LinkedHashMap
LinkedMap

  treemap  collections  java  sorted collections  map

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

  linkedhashmap  collections  java  map

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

If we try to add duplicate key to the HashMap, What will happen ?Core Java
It will throw an exception.
It won't add the new Element without any exception.
The new element will replace the existing element.
Compiler will identify the problem and will throw an error.

  hashmap  map  collections  java

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

Which interface does java.util.Hashtable implement ?Core Java
List
Set
Collection
Map

  hashtable  java  collections

Which of the following is false ?Core Java
HashMap came before HashTable.
HashMap allows null values whereas Hashtable doesn’t allow null values.
HashTable and HashMap allow Key-Value pairs.
Hashtable is synchronized whereas HashMap is not.

  map  hashmap  hashtable  collection  java

Which of the collections allows null as the key ?Core Java
HashTable
HashMap
TreeMap
LinkedHashMap

  java  collections  map

Collections.sort can only be performed on ..Core Java
Set
List
Map
Any Collection implementation

  collections  java  sorting

Effective Java 6 , TreeMap implements ...Core Java
Map Interface
SortedMap Interface
NavigableMap Interface
SortedNavigableMap Interface

  java  collections  map

Which of the following doesn't extend Collection interface ?Core Java
Set
List
Map
Queue

  java  collections  collection interface

Collections is a / an ..Core Java
interface
abstract class
final class
util class

  collections

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 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

Which of the following collections stores its elements in natural sorting order ?Core Java
HashMap
LinkedHashMap
TreeMap
EnumMap

  map  collections

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

  set  collections

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 collection classes store their elements as Key Value pairs ?Core Java
Set
List
Map
Queue

  collections

Which keyword is used to provide explicit access of a code block to single thread ?Core Java
Transient
Final
Explicit
Synchronized

  java  threads  multithreading

enums are intrinsically ..Core Java
private
public
static
final

  java  enum

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

  java  enum

Which method needs to be implemented if a class is implementing comparable interface ?Core Java
comp
compare
compareTo
compareEquals

  comparable  interfaces  compare  compareTo

Which of the following is false ?Core Java
A Class cannot override both hashcode and equals method.
A class can override both hashcode and equals method.
A Class must override hashCode method if its overridding equal method.
A Class can override hashCode even if its not overridding equals method.

  hascode  equals method  overridding hashcode and equals method

Binary Search requires that the collection should beAlgorithm
Sorted in Ascending Order
Sorted in Descending Order
Sorted in any Order
Unsorted

  Binary Search  Search  Algorithm







comments powered by Disqus