Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class ComputerRequirements {
    public static void main(String[] args) {
        IdentityHashMap var = new IdentityHashMap<>();
        if (var.isEmpty()) {
            var.put("A/C", new Integer(10000));
            var.put("Computer", new Integer(35000));
            var.put("Table", new Integer(3000));
            var.put("Table", new Integer(3000 - 500));
            var.put("Webcam", new Integer(1500));
            var.put("UPS", new Integer(2600));
        }
        System.out.println("Table Cost = " + var.get("Table"));
        Integer balance = ((Integer) var.get("Table")).intValue();
        var.put("Table", new Double(balance + 1000));
        System.out.println("Table Cost = " + var.get("Table"));
    }
}


Table Cost = 2500
Table Cost = 2500
Table Cost = 3000
Table Cost = 3000
Table Cost = 2500
Table Cost = 3500
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