What will be the output of the following program?

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

public class Program {
public static void main(String... args) {
String k1 = "key1";

Map map = new Hashtable();

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

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

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


a. value1
value2
HashMap allows null values as keys, so it will be matched and value2 will be displayed.

Computer Science & Information Technology

You might also like to view...

According to the ISO 12207 standard, parties much agree to what items prior to an audit?

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

What cannot be copyrighted?

a. facts b. opinions c. new ideas d. old ideas

Computer Science & Information Technology

Variables defined inside a function body are considered _____.

a. local b. illegal c. constant d. format parameters e. actual arguments

Computer Science & Information Technology

Double-clicking the border between two columns to resize a column to accommodate the largest entry is called:

A) fitting. B) AutoSizing. C) AutoFit. D) resizing.

Computer Science & Information Technology