Menu
Topics Index
...
`

Add items to Dictionary


If you need explanation Read this topic

If you need Answer Take test on this topic

Add items to Dictionary
What will be the output of the following program?
import java.util.*;
public class TouchMe {
    public static void main(String[] args) {
        Dictionary d = new Hashtable();
        d.put(1, "Mobile");
        d.put(2, "Laptop");
        d.put(3, "Desktop");
        d.put(4, "Notebook");
        for (int i = 1; i <= 4; i++) {
            System.out.print(d.get(i) + ", ");
        }
    }
}

A. Mobile, Laptop, Desktop, Notebook,
B. Notebook, Desktop, Laptop, Mobile,
C. Compilation Error
D. Runtime Error
Topic: Java Dictionary Class - java.util.Dictionary

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

A. is the answer . simply for loop prints the items in the dictionary.

Posted by Shabaaz Shaikz    2014-01-10 13:05:15


Congratulations Shabaaz Shaikz. You are this dose winner. We will send you a link using which you can claim your recharge.

Posted by Merit Campus    2014-01-13 13:44:06


:-) ..thnks MC>

Posted by Shabaaz Shaikz    2014-01-13 13:54:03


© meritcampus 2019

All Rights Reserved.

Open In App