Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class CollectionQueue
{
    public static void main(String args[])
    {
        Deque<String> arrayDeque = new ArrayDeque<String>(2);
        arrayDeque.add("1");
        arrayDeque.add("2");
        arrayDeque.add("3");
        arrayDeque.add("4");
        arrayDeque.add("5");

        System.out.println(arrayDeque);
        System.out.println(Collections.asLifoQueue(arrayDeque));
    }
}


[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
[1, 2]
[2, 1]
[1, 2]
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
[5, 4, 3, 2, 1]
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Collection Algorithms

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App