Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class MapExample {
    public static void main(String args[]) {
        NavigableMap<Integer, String> map = new TreeMap<Integer, String>();
        map.put(2, "two");
        map.put(1, "one");
        map.put(3, "three");
        map.put(6, "six");
        map.put(5, "five");
        System.out.println("Value returned: " + map.pollFirstEntry());
        System.out.println("Value after poll: " + map);
    }
}


Value returned: 1=one
Value after poll: {2=two, 3=three, 5=five, 6=six}
Value returned: 1=one
Value after poll: {1=one, 2=two, 3=three, 5=five, 6=six}
Value returned: 2=two
Value after poll: {1=one, 3=three, 5=five, 6=six}
Value returned: 2=two
Value after poll: {1=one, 2=two, 3=three, 5=five, 6=six}
Compilation Error or Runtime Error

Doubts

Problems

Topic: TreeMap In Java - java.util.TreeMap

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App