J2EEOnline J2EE   

Java Certification Questions 1 - 10   «Prev  Next»
Java Questions 2
  1. What is the natural order for sorting objects?
    For a collection of String objects, the natural order is alphabetical. For Integer objects, the natural order is by numeric value. [Page 561 SCJP by K.S.]
  2. What are all 3 list implementations ordered by?
    All 3 list implementations are ordered by index position, a position that you determine either by setting an object at a specific index or by adding it without specifying position,
    in which case the object is added to the end.
  3. What is the difference between an ArrayList and a LinkedList?
    In a LinkedList the elements are doubly-linked to one another.
  4. What is characterisitc of the Set Interface?
    A set cares about uniqueness and does not allow duplicates.
  5. When should you use the HashSet class?
    Use this class when you want a collection with no duplicates and you do not care about order when you iterate through it.
  6. When should you use the LinkedHashSet?
    1. Use this class instead of HashSet when you care about the iteration order.
    2. A LinkedHashSet lets you iterate through the elements in the order in which they were inserted. [P563 SCJP by K.S.]
  7. What set does TreeSet implement?
    As of Java 6, TreeSet implements NavigableSet.
  8. Which method do Maps rely on to determine whether two keys are the same or different?
  9. When should you use a HashMap?
    When you need a Map and do not care about the order (when you iterate through it), then you should select HashMap.
  10. What are the key differences between HashMap and Hashtable?
    Hashtable is the synchronized counterpart to HashMap.
    When we say Vector and Hashtable are synchronized, we mean that the key methods of the class are synchronized.
    A HashMap lets you have null values as well as one null key, a Hashtable does not allow anything that is null.