This post originated from an RSS feed registered with Java Buzz
by instanceof java.
Original Post: Top 20 collection framework interview questions and answers in java
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
To sort the array of objects we will use Arrays.sort() method.
If we need to sort collection of object we will use Collections.sort().
5.What is difference between fail-fast and fail-safe?
Fail fast is nothing but immediately report any failure. whenever a problem occurs fail fast system fails.
in java Fail fast iterator while iterating through collection of objects sometimes concurrent modification exception will come there are two reasons for this.
If one thread is iterating a collection and another thread trying to modify the collection.
And after remove() method call if we try to modify collection object
6. What is difference between Iterator ,ListIterator and Enumeration?
Enumeration interface implemented in java 1.2 version.So Enumeration is legacy interface.
Enumeration uses elements() method.
Iterator is implemented on all Java collection classes.
Iterator uses iterator() method.
Iterator can traverse in forward direction only.
ListIterator is implemented only for List type classes