Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Months {
    public static void main(String args[]) {
        SortedMap map = new TreeMap();
        map.put("January", 1);
        map.put("March", 3);
        map.put("June", 6);
        map.put("August", 8);
        Iterator it = map.keySet().iterator();
        while (it.hasNext()) {
            Object key = it.next();
            System.out.print(key + "-" + map.get(key) + ", ");
        }
    }
}


January-1, March-3, June-6, August-8,
August-8, June-6, March-3, January-1,
August-8, January-1, June-6, March-3,
January-1, June-6, March-3, August-8,
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