Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class GetValue {
    public static void main(String a[]) {
        List li = new ArrayList<Integer>();
        ListIterator<Integer> litr = null;
        li.add('A');    li.add('B');
        li.add('C');    li.add('D');
        li.add('E');

        li.add('1');    li.add('2');
        li.add('3');    li.add('4');
        li.add('5');

        li.add(6);    li.add(7);
        li.add(8);    li.add(9);
        li.add(10);
        litr = li.listIterator();
        while (litr.hasNext()) {
            System.out.print(litr.next() + ", ");
        }
    }
}


A, B, C, D, E,
1, 2, 3, 4, 5,
6, 7, 8, 9, 10,
A, B, C, D, E, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
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