Search Header Logo

Queue

Authored by Najma Parveen

Information Technology (IT)

University

Used 2+ times

Queue
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Queue<Integer> q = new LinkedList<>();

q.add(10);

q.add(20);

q.add(30);

System.out.print(q.poll() + " ");

System.out.print(q.peek());

10 20

20 30

10 30

Error

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which operation is possible in a Deque?

Insert only at front

Insert only at rear

Insert/Delete at both ends

Only delete

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Deque<Integer> dq = new ArrayDeque<>();

dq.offerFirst(1);

dq.offerLast(2);

dq.offerFirst(3);

dq.pollLast();

dq.offerLast(4);

dq.pollFirst();

System.out.print(dq);

[1, 4]

[2, 4]

[3, 2]

[1, 2]

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

PriorityQueue<Integer> pq = new PriorityQueue<>();

pq.add(7);

pq.add(2);

pq.add(9);

pq.add(1);

pq.remove(7);

System.out.print(pq.poll());

1

2

7

9

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Deque<Integer> dq = new ArrayDeque<>();

dq.add(10);

dq.add(20);

dq.add(30);

Iterator<Integer> it = dq.descendingIterator();

while(it.hasNext())

System.out.print(it.next()+" ");

10 20 30

30 20 10

Random order

Error

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Queue<Integer> q = new PriorityQueue<>();

q.add(3);

q.add(1);

q.add(2);

while(!q.isEmpty())

System.out.print(q.poll());

312

123

231

Random

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

PriorityQueue<Integer> pq = new PriorityQueue<>();

pq.add(5);

pq.add(2);

pq.add(8);

pq.add(1);

System.out.print(pq.poll() + " ");

pq.add(0);

System.out.print(pq.poll());

1 0

1 2

2 0

0 1

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?