Vidyalelo
Java Programming · Q134

Java Collections Framework

Programming · Java Programming · question 134

Q134

What will be the output of the following Java code snippet? public class Demo public static void main(String[] args) Map sampleMap = new TreeMap(); sampleMap.put(1, null); sampleMap.put(5, null); sampleMap.put(3, null); sampleMap.put(2, null); sampleMap.put(4, null); System.out.println(sampleMap);

A.
{1=null, 2=null, 3=null, 4=null, 5=null}
Answer
B.
{5=null}
C.
Exception is thrown
D.
{1=null, 5=null, 3=null, 2=null, 4=null}

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board