FUNDAMENTALS OF COMPUTER

DATABASE FUNDAMENTALS

BASICS OF BIG DATA

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of these iterators can be used only with List?
A
Setiterator
B
ListIterator
C
Literator
D
None of the mentioned
Explanation: 

Detailed explanation-1: -4. Which of these iterators can be used only with List? Explanation: None.

Detailed explanation-2: -An Iterator is an interface in Java and we can traverse the elements of a list in a forward direction whereas a ListIterator is an interface that extends the Iterator interface and we can traverse the elements in both forward and backward directions.

Detailed explanation-3: -Iterator object can be created by calling iterator() method present in Collection interface. It is only applicable for List collection implemented classes like arraylist, linkedlist etc. It provides bi-directional iteration. ListIterator must be used when we want to enumerate elements of List.

Detailed explanation-4: -The ListIterator interface of the Java collections framework provides the functionality to access elements of a list. It is bidirectional. This means it allows us to iterate elements of a list in both the direction. It extends the Iterator interface.

Detailed explanation-5: -While a ListIterator can be used to traverse for List-type Objects, but not for Set-type of Objects.

There is 1 question to complete.