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.put(k1, "value1");
map.put(k2, "value2");
System.out.println(map.get(k1));
System.out.println(map.get(k2));
}
}
class Key {
public int hashCode() {
return 1;
}
}
a. value1
value2
b. null
null
c. value2
value2
d. A Runtime Exception will be thrown.
a. value1
value2
It doesn't matter that hashCode returns a constant value.
You might also like to view...
An external style sheet uses the _____ file extension.
a. ess b. css c. htm d. No file extension is necessary
____________________ is the ratio of the largest to smallest (nonzero) magnitude of a variable quantity.
Fill in the blank(s) with the appropriate word(s).
To change the width of a column, you click Column Width in the ________ tab
A) Cells group on the Home tab B) Adjustment group on the Home tab C) Adjustment group on the Format tab D) Cells group on the Format tab
With the database approach, most data items are stored in multiple files, which greatly reduces duplicate data.
Answer the following statement true (T) or false (F)