Sail E0 Webinar
Question


What is the output of this program?


import java.util.*;
class hashtable {
public static void main(String args[]) {
Hashtable obj = new Hashtable();
obj.put("A", new Integer(3));
obj.put("B", new Integer(2));
obj.put("C", new Integer(8));
System.out.print(obj.contains(new Integer(5)));
}
}
Options:
A .  0
B .  1
C .  true
D .  false
Answer: Option D

Hashtable object obj contains values 3, 2, 8 when obj.contains(new Integer(5)) is executed 

it searches for 5 in the hashtable since it is not present false is returned.

Output:
$ javac hashtable.java
$ java hashtable
false



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers