Java Collections Programming Interview Questions Answers - 2
Question: 6
What is an iterator?
- Iterator interfaces provides methods to iterate over any Collection.
- We can get iterator instance from a Collection using iterator() method.
- Iterator takes the place of Enumeration in the Java Collections Framework.
- Iterators allow the caller to remove elements from the underlying collections during the iteration.
- Java Collection iterator provides a generic way for traversal through the elements of a collection and implements Iterator Design Pattern.
Question: 7
What are collection related features in java 8?
Java 8 has brought major changes in the Collection API. Some of the changes are
Java Stream API for collection classes for supporting sequential as well as parallel processing.
Iterable interface is extended with forEach() default method that we can use to iterate over a collection.
It is very helpful when used with lambda expressions because its argument.
Question: 8
How do you remove element during iteration?
Iterator also has a method remove() when remove is called, the current element in the iteration is deleted.
Question: 9
Why we override equals() method?
The equals() method is used to check whether two objects are same or not.
It needs to be overridden if we want to check the objects based on property.
Question: 10
How will you load a specific locale?
By ResourceBundle.getBundle() method.
Samacheer Kalvi Class 11 Taxonomy Systematic Botany Questions More
Photosynthesis in Higher Plants MCQ Questions and Answers More
The Living World Class 11 Questions and Answers Pdf Download More
Samacheer Kalvi Class 11 Bio Botany Photosynthetic Questions More
Samacheer Kalvi Class 11 Bio Botany Cell Cycle Questions More
Vocabulary Test Questions and Answers for Bank Exams More
1000+ Computer Programming Questions and Answers Pdf More
Refractory Technology Objective Quiz Questions and Answers More
1000+ A.C. Fundamentals, Circuits and Circuit Theory MCQ Questions Pdf More
1000+ Environmental Science and Engineering MCQ Questions & Answers More