Menu
Question Index
...

What will be the output of following program?

import java.util.*;

public class PlayingCards {
    public static void main(String[] args) {
        ArrayDeque<String> ad = new ArrayDeque<String>();
        ad.add("Ace");
        ad.add("Jack");
        ad.add("Queen");
        ad.add("King");
        p(ad.peek());
        p(ad.peekFirst());
        p(ad.peekLast());
        p(ad.contains("Ace"));
        p(ad.poll());
        p(ad.pollLast());
        p(ad.pollFirst());
        p(ad.contains("King"));
    }
    private static void p(Object obj) {
        System.out.print(obj + "*");
    }
}


Ace*King*Ace*true*King*Ace*Jack*false*
Ace*Ace*King*true*Ace*King*Jack*false*
Ace*Ace*King*true*Ace*King*King*true*
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