Menu
Topics Index
...
`

Colleges 2406


If you need explanation Read this topic

If you need Answer Take test on this topic

Colleges 2406
What will be the output of the following program?
import java.util.*;
public class Colleges {
    public static void main(String args[]) {
        Map map = new HashMap();
        map.put(1, "KSRM");
        map.put(2, "AITS");
        map.put(3, "Madina");
        Set set = map.entrySet();
        System.out.println("Set mappings are :");
        Map.Entry me = (Map.Entry) set;
        System.out.println(me);
    }
}

A. [1=KSRM, 2=AITS, 3=Madina]
B. {1=KSRM, 2=AITS, 3=Madina}
C. Compilation Error 
D. Runtime Error
Topic: Java HashMap Implementation

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans:D raises exception classcast exception

Posted by Indra Chereddy    2014-06-06 13:14:21


option b is correct as the method returns the key value pairs in square brackets seperatd by ,

Posted by Vijay Kumar    2014-06-06 13:18:24


ans d. Map.Entry me=(Map.Entry)set; tis line throws class cast exception

Posted by Maheshwari Natarajan    2014-06-06 13:19:53


No winner for this dose. Correct option is 'D' :(. Indrasena Reddy was already won in this week.

Posted by Merit Campus    2014-06-09 11:38:05


© meritcampus 2019

All Rights Reserved.

Open In App