What is the difference between Iterator and Enumeration?

Iterator
Enumeration
It is useful to retrieve object
From a collection
It’s also useful to retrieve object
From a collection
Iterator has methods whose
Names are easy to follow
Enumeration has methods whose
Names are difficult to remember
Iterator has an option to remove
Objects from a collection
Which is not available
So Iterator is preferred than Enumeration

What is the difference between Iterator and ListIterator?

  • Both are useful to retrieve elements from a collection.
  • Iterator can retrieve the elements only in forward direction.
  • But ListIterator can retrieve the elements in forward and backward direction also.
  • So ListIterator is preferred than Iterator

What is map in collection framework?

  • Maps stored elements in the form of key and value pairs.
  • If key is provided then its corresponding value can be obtained.
  • Of course key should have unique values.

What is a queue in collections framework?

  • A queue represents arrangements of elements in FIFO(Firs In First Out) order.
  • This means that element that is stored as a first element into the queue will be removed first from the queue.

What is lists in collection framework?

  • Lists are like Sets.
  • They store a group of elements,
  • But Lists allow duplicate values to be stored.

What is a set?

  • A set represents a group of elements arranged just like an array.
  • The set will grow dynamically when the elements are stored into it.
  • A set will not allow duplicate elements.
  • If we try to pass same element that is already available in the set, then it is not stored into it.
  • Set will not maintain the same order of elements as in which they were entered.

What is the differences between Java5 and Java6?





JAVA-5
JAVA-6
Also known as  Tiger
Also known as  Mustang
  •      Generics—Provides compile-time type safety for collections and eliminates the need for casting every time you get an object out of Collections.
  •  Enhanced For loop—Eliminates error-proneness of iterators.
  • Autoboxing/unboxing—Eliminates need of manual conversion between primitive types (such as double) and wrapper types (such as Double).
  • Typesafe enumsProvides all benefits of the Typesafe enum pattern.
  • Static import—Eliminates the need for using class names prior to using the static member variables of other classes. This will make the code a bit neater.
  • Metadata—Allows  programmers to avoid writing boiler plate code and gives the opportunity for declarative programming.
  • Annotation Processing API (JSR 269)
  • Common Annotations (JSR 250)
  • Java API for XML Based Web Services - 2.0 (JSR 224)
     JAXB 2.0 (JSR 222)
  • Web Services Metadata (JSR 181)
  • Streaming API for XML (JSR 173)
  • XML Digital Signature (JSR 105)
  • Java Class File Specification Update (JSR 202)
  • Java Compiler API (JSR 199)
  • JDBC 4.0 (JSR 221)
  • Scripting in the Java Platform (JSR 223)