Menu
Question Index
...

What could be the output of the following program?

import java.util.*;
class Fruits {
    public static void main(String a[]) {
        HashMap<Integer, String> frt = new HashMap<Integer, String>();
        frt.put(1, "apple");
        frt.put(3, "banana");
        frt.put(5, "mango");
        HashMap<Integer, String> sub = new HashMap<Integer, String>();
        sub.put(4, "grapes");
        sub.put(7, "orange");
        frt.putAll(sub);
        System.out.print(frt);
    }
}


{1=apple, 3=banana, 4=grapes, 5=mango, 7=orange}
{1=apple, 3=banana, 5=mango}
Compilation Error
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