Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Collect {
    public static void main(String[] args) {
        ArrayDeque ad = new ArrayDeque<>();
        ad.add(15);
        ad.add(25);
        ad.add(35);
        ad.add(45);
        ad.add(55);
        ad.add(65);
        ad.add(75);
        ad.add(85);
        System.out.print(ad.peek() + ", ");
        System.out.print(ad.peekFirst());
        ad.addFirst(5);
        ad.addLast(95);
        System.out.println(", " + ad);
    }
}


95, 15, [95, 15, 25, 35, 45, 55, 65, 75, 85, 5]
95, 15, [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]
15, 15, [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]
15, 15, [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java ArrayDeque Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App