What will be the output of the following program?

import java.util.HashMap;
import java.util.Map;

public class Program {
public static void main(String... args) {
Key k1 = new Key();
Key k2 = new Key();

Map map = new HashMap<>();

map.put(k1, "value1");
map.put(k2, "value2");

System.out.println(map.get(k1));
System.out.println(map.get(k2));
}
}

class Key {
public boolean equals(Object o) {
return true;
}
public int hashCode() {
return 1;
}
}

a. value2
value2
b. null
null
c. value1
value2
d. A Runtime Exception will be thrown.

a. value2
value2

Computer Science & Information Technology

You might also like to view...

If you design a class with private data members, and do not provide mutators and accessors, then

a. The private data members can still be accessed from outside the class by using the & operator b. The data can not be changed or viewed by anyone. c. None of the above d. A and B

Computer Science & Information Technology

Identify a true statement about deleting a graphic in a theme on a PowerPoint slide. 

A. ?It can only be done one slide at a time. B. ?It can be done in a Slide Master view. C. ?It cannot be done for text within a graphic. D. ?It cannot be done in the Outline Master view.

Computer Science & Information Technology