Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class Sachin {
    public static void main(String... l) {
        List<String> li = new ArrayList<String>();
        li.add("Hello");
        li.add("Madam");
        ListIterator i = li.listIterator();
        while (i.hasNext()) {
            i.add("Hi");
            i.next();
            li.add("Hll");
        }
        System.out.println(li);
    }
}


[Hello, Madam, Hi, Hi, Hll, Hll]
[Hi, Hello, Hll, Hi, Madam, Hll]
throws IllegalStateException
throws ConcurrentModificationException
Compilation Error or Runtime Error for some other reason

Doubts

Problems

Topic: List Iterator In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App