Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class TwoInOne {
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add("M");    list.add("N");
        list.add("O");    list.add("P");
        list.add("Q");
        ListIterator listIt = list.listIterator();
        listIt.next();    listIt.next();
        listIt.next();    listIt.next();
        listIt.remove();    listIt.previous();
        listIt.previous();    listIt.remove();
        System.out.println(list);
    }
}


[M, O, Q]
[M, N, O, P, Q]
Some other output
Compilation Error
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