What will be the output of following quiz on ArrayDeque ?
© 2016, https:. All rights reserved. On republishing this post, you must provide link to original post
0 of 1 questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Time has elapsed
package com.topjavatutorial; import java.util.ArrayDeque; public class ArrayDequeDemo { public static void main(String[] args) { ArrayDeque<String> adq = new ArrayDeque<String>(); adq.add("A"); adq.push("B"); adq.addFirst("C"); adq.offer("D"); System.out.print(adq.peek() + " " + adq.pop() + " " + adq.poll()); } }
push() and addFirst() add elements at front of queue and add() and offer() add elements at end of queue.
peek() just retrieves the element, does not remove it.
pop() and poll() remove from front of queue.
Refer following post to understand ArrayDeque operations:
push() and addFirst() add elements at front of queue and add() and offer() add elements at end of queue.
peek() just retrieves the element, does not remove it.
pop() and poll() remove from front of queue.
Refer following post to understand ArrayDeque operations:
© 2016, https:. All rights reserved. On republishing this post, you must provide link to original post