Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class StudentStatus {
    public static void main(String[] args) {
        IdentityHashMap var = new IdentityHashMap<>();
        if (var.isEmpty()) {
            var.put("Kiran", 1);
            var.put("Ashok", 2);
            var.put("Dharma", 3);
            var.put("Muneer", 4);
        }
        Set s = var.entrySet();
        Iterator itr = s.iterator();
        while (itr.hasNext()) {
            Map.Entry m = (Map.Entry) itr.next();
            System.out.println(m.getKey() + " rank is " + m.getValue());
        }
    }
}


Kiran rank is 1
Ashok rank is 2
Dharma rank is 3
Muneer rank is 4
Ashok rank is 2
Dharma rank is 3
Kiran rank is 1
Muneer rank is 4
Dharma rank is 3
Ashok rank is 2
Muneer rank is 4
Kiran rank is 1
Some other output
Output Can not be determined
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java IdentityHashMap

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App