Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class MovieNames {
    public static void main(String args[]) {
        Map map = new HashMap();
        map.put(1, "Bahubali");
        map.put(2, "Evadu");
        map.put(3, "Dopidi");
        System.out.println(map);
        map.clear();
        System.out.print("After clear: " + map);
    }
}


[1=Bahubali, 2=Evadu, 3=Dopidi]
After clear:
{1=Bahubali, 2=Evadu, 3=Dopidi}
After clear: {}
{1Bahubali, 2Evadu, 3Dopidi}
After clear:
[1Bahubali, 2Evadu, 3Dopidi]
After clear:[]
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java HashMap Implementation

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App