Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class RemoveThis {
    public static void main(String[] args) {
        List xl = new ArrayList();
        xl.add("A");    xl.add("B");
        xl.add("C");    xl.add("D");
        xl.add("E");    xl.add("F");
        xl.add("G");    xl.add("H");
        xl.add("I");    xl.add("J");
        xl.add("K");

        ListIterator lt = xl.listIterator();
        lt.next();    lt.next();
        lt.next();    lt.next();
        lt.next();    lt.next();
        lt.remove();    lt.previous();
        lt.previous();    lt.next();
        lt.remove();    lt.previous();
        lt.next();    lt.previous();
        lt.remove();
        System.out.print(xl);
    }
}


[A, C, E, G, H, I, J, K]
[A, B, D, F, G, H, I, J, K]
[B, D, F, G, H, I, J, K]
[A, B, E, G, H, I, J, K]
Some other output
Compilation Error or Runtime Error

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