-
What is the output of this program?
import java.util.*;
public class hashtable_Example
{
public static void main(String args[])
{
Hashtable object = new Hashtable();
object.put("P", new Integer(12));
object.put("Q", new Integer(21));
object.put("R", new Integer(18));
System.out.print(object.toString());
}
}
-
- {R=18, Q=21}
- {Q=21, P=12}
- {R=18, P=12}
- {R=18, Q=21, P=12}
- {P=12, R=18}
Correct Option: D
object.toString returns String equivalent of the hashtable, which can also be obtained by simply writing System.out.print(object); as print system automatically converts the object tostring equivalent.