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...

What does iterable mean? Name two builtin objects that are iterable. Which control structure can you use to loop through an iterable object?

What will be an ideal response?

Computer Science & Information Technology

________ is the naming conversation for tables and field names used by SQL database programmers

A) Lower Case Convention B) Lower Camel Case C) Upper Case Convention D) Upper Camel Case

Computer Science & Information Technology

You have a Hyper-V server with about 1 TB of free disk space. You want to configure four virtual machines, with each having a 300 GB disk drive. The VMs' virtual disks will reside on the Hyper-V server. How should you configure these VMs?

a. Using Features on Demand b. Using tiered storage c. Using thin provisioning d. Using differencing disks

Computer Science & Information Technology

________ can be used for a limited period that allows the user to try it out before purchasing a license

a. Donationware b. Freeware c. Retail d. Shareware

Computer Science & Information Technology