Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Tree {
    public static void main(String args[]) {
        NavigableMap tree = new TreeMap();
        tree.put(1, "leaf");
        tree.put(3, "root");
        tree.put(5, "stem");
        tree.put(4, "branch");
        System.out.println(tree.pollLastEntry());
        System.out.print(tree);
    }
}


5=stem
{1=leaf, 3=root, 4=branch}
4=branch
{1=leaf, 3=root, 5=stem, 4=branch}
4=branch
{1=leaf, 3=root, 5=stem}
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