Java Queue Questions (122)
- How does a PriorityQueue order its elements?
Answer: A PriorityQueue orders its elements using a user-defined priority?
- Which interface does a PriorityQueue implement to impose an ordering other than ânatural orderingâ?
Answer:
The Comparator interface.
- What does the T[] syntax represent?
Answer: This syntax represents an array that is not an array of primitives.
- Can the Iterator interface be used with the Map interface?
Answer: No. The Iterator interface will get an Iterator for a List or a Set.
- What are the relative positions of uppercase characters, lowercase characters, and spaces in a natural ordering?
Answer: Spaces sort before characters and uppercase letters sort before lowercase characters.
- What is the difference between NavigableSet and NavigableMap interfaces?
Answer:
NavigableSet<E> inherits from Iterable<T> .
NavigableMap<K,V> inherits from Map<K,V> .
- Why were Generics added to the Java language?
Answer: Collections are the overwhelming reason and motivation for adding generics to the language.
- Can you integrate Java 5 and Java 6 generic code with legacy non-generic code?
Answer:
Yes, but most of the errors will occur at run time
- How many ways can we track client and what are they?
Answer:
The servlet API provides two ways to track client state and they are:
- Using Session tracking and
- Using Cookies.
- What is a characteristic of a non-generic collection?
Answer:
A non-generic collection can hold any kind of object. A non-generic collection is quite happy to hold anything that is NOT a primitive.