Question
import java.util.*;
class Maps {
public static void main(String args[]) {
TreeMap obj = new TreeMap();
obj.put("A", new Integer(1));
obj.put("B", new Integer(2));
obj.put("C", new Integer(3));
System.out.println(obj.entrySet());
}
}
What is the output of this program?
import java.util.*;
class Maps {
public static void main(String args[]) {
TreeMap obj = new TreeMap();
obj.put("A", new Integer(1));
obj.put("B", new Integer(2));
obj.put("C", new Integer(3));
System.out.println(obj.entrySet());
}
}
Answer: Option D
Was this answer helpful ?
obj.entrySet() method is used to obtain a set that contains the entries in the map.
This method provides set view of the invoking map.
Output:
$ javac Maps.java
$ java Maps
[A=1, B=2, C=3]
Was this answer helpful ?
Submit Solution