πŸ“Š JAVA
Q. What will be the output of given code
Code:
import java.util.ArrayList;
import java.util. Iterator;
import java.util. List;

public class ArrayListTest {
public static void main (String args[])
{
List<String> arrayList = new ArrayList<String>();

arrayList.add(“a”);
arrayList.add(“b”);

Iterator<String> iterator = arrayList.iterator();

while (iterator.hasNext())
{
System.out.println(iterator.next());
arrayList.add(“c”);
}
}
}
  • (A) a followed by ConcurrentModificationException
  • (B) a b c
  • (C) a b
  • (D) a c
πŸ’¬ Discuss
βœ… Correct Answer: (A) a followed by ConcurrentModificationException

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
222
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Tina Singh
Publisher
πŸ“ˆ
86%
Success Rate