Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Districts {
    public static void main(String args[]) {
        SortedMap map = new TreeMap();
        map.put("Kadapa", 1);
        map.put("Ananthapur", 2);
        map.put("Kurnool", 3);
        map.put("Chittoor", 4);
        System.out.println("first value: " + map.firstKey());
        System.out.print("last value: " + map.lastKey());
    }
}


first value: Kadapa
last value: Chittoor
first value: Ananthapur
last value: Kurnool
first value: Ananthapur
last value: Chittoor
first value: Chittoor
last value: Kurnool
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