Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class HashSearch1
{
    public static void main(String args[])
    {
        Hashtable<String, String> hm = new Hashtable<String, String>();
        hm.put("A", "1");
        hm.put("B", "2");
        hm.put("C", "3");
        
        if(hm.containsValue("A"))
        {
            System.out.println("The Hashtable contains value");
        }
        else
        {
            System.out.println("The Hashtable does not contains value.");
        }
        
        if(hm.containsValue("2"))
        {
            System.out.println("The Hashtable contains value.");
        }
        else
        {
            System.out.println("The Hashtable does not contains value.");
        }
    }
}


The Hashtable contains value.
The Hashtable does not contains value.
The Hashtable does not contains value.
The Hashtable contains value.
The Hashtable contains value.
The Hashtable contains value.
The Hashtable does not contains value.
The Hashtable does not contains value.
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Hashtable

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App