Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
import java.util.concurrent.*;
public class BlockingDequeTest {
    public static void main(String... args) {
        LinkedBlockingDeque lbd = new LinkedBlockingDeque();
        lbd.add("B");
        lbd.add("A");
        lbd.add("C");
        lbd.add("D");
        lbd.addFirst("E");
        lbd.addLast("F");
        List list = new ArrayList();
        lbd.drainTo(list, 2);
        show(list.iterator(), "List");
        show(lbd.iterator(), "LBL");
    }
    public static void show(Iterator itr, String msg) {
        while (itr.hasNext()) {
            String s = (String) itr.next();
            System.out.print(s + " ");
            itr.remove();
        }
        System.out.println();
    }
}


E B
A C D F
A C D F
E B
E F
B A C D
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Other Advanced Topics In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App