Menu
Topics Index
...
`

Creating Map


If you need explanation Read this topic

If you need Answer Take test on this topic

Creating Map
What will be the output of the following program?
import java.util.*;

public class DemoOnMaps {
    public static void main(String args[]) {
        Map<Planning, String> objects = new HashMap<Planning, String>();
        Planning planning1 = new Planning("Monday");
        Planning planning2 = new Planning("Tuesday");
        Planning planning3 = new Planning("Tuesday");
        objects.put(planning1, "Reading");
        objects.put(planning2, "Dancing");
        objects.put(planning3, "Drawing");
        System.out.println("Size :" + objects.size());
    }
}

class Planning {
    String day;
    public Planning(String today) {
        day = today;
    }
    public boolean equals(Object object) {
        return ((Planning) object).equals(day);
    }
}

A. Size :3
B. Size :2
C. Some other output
D. Compilation Error or 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 is a..the size of map is 3

Posted by Uday Kumar    2014-07-25 13:05:04


ans a .
hre 3 planing objects are creatd and initialzd.
and using put operatn ths values plcd .
size of the map 3

Posted by Maheshwari Natarajan    2014-07-25 13:10:58


A

Posted by Ria Gupta    2014-07-25 14:51:51


Congratulations Uday Kumar. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-07-28 06:51:48


© meritcampus 2019

All Rights Reserved.

Open In App