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.
Electrical Power Sources Quiz Questions & Answers Pdf More
Electromagnetic Field Theory Question Bank 2024-2025 More
Power Semiconductor Device and Integrated Circuits Questions More
Strength of Materials Questions and Answers Pdf More
Steam and Power Generation Quiz Questions & Answers Pdf More
Java J2EE Multiple Choice Questions and Answers More
1000+ Electrical Machines Quiz Questions and Answers Pdf More
1000+ Chemical Engineering Multiple Choice Questions and Answers More
Puzzles Interview Questions and Answers Pdf More
List of Important Common Drugs and their Uses More