Question
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)));
}
}
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)));
}
}
Answer: Option D
Was this answer helpful ?
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 ?
Submit Solution