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. A NullPointer Exception will be thrown.
b. value1
value2
c. value1
d. value1
null

a. A NullPointer Exception will be thrown.
Hashtable does not allow null as key, so a NullPointer Exception will be thrown.

Computer Science & Information Technology

You might also like to view...

Using a palm scan for authentication is an example of which of the following?

A) Authentication by knowledge B) Authentication by ownership C) Authentication by characteristic D) Authentication by possession

Computer Science & Information Technology

Placing navigation links in an unordered list nested within a ____ element is a common technique used in Web design.

A. block B. link C. menu D. nav

Computer Science & Information Technology