logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

  • Question
  • How do you decide when to use HashMap and when to use TreeMap ?


  • Correct Answer
  • For inserting, deleting, and locating elements in a Map, the HashMap offers the best alternative If, however, you need to traverse the keys in a sorted order, then TreeMap is your better alternative Depending upon the size of your collection, it may be faster to add elements to a HashMap, then convert the map to a TreeMap for sorted key traversal 


  • Technology problems


    Search Results


    • 1. How are this() and super() used with constructors?
    • Discuss
    • 2. Just by seeing the signature of the bean how can you specity whether it is a Statefull of Stateless Session Bean?
    • Discuss
    • 3. Difference between Java Beans & Servlets?
    • Discuss
    • 4. try { int x = Integer.parseInt("two"); } Which could be used to create an appropriate catch block?

    • Options
    • A. ClassCastException
    • B. IllegalStateException
    • C. NumberFormatException
    • D. None
    • Discuss
    • 5. class Hell { public static void main(String[] args) { Integer i = 42; String s = (i<40)?"life":(i>50)?"base":"ball"; System.out.println(s); } }

    • Options
    • A. null
    • B. ball
    • C. base
    • D. None
    • Discuss
    • 6. What is the Dictionary class?
    • Discuss
    • 7. What is the common usage of serialization? What exceptions occur during serialization?
    • Discuss
    • 8. What is the purpose of garbage collection in Java, and when is it used ?
    • Discuss
    • 9. When is the finalize() called ? What is the purpose of finalization ?
    • Discuss
    • 10. What is Marker Interface?
    • Discuss


    Comments

    There are no comments.

Enter a new Comment