Menu
Question Index
...

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", "Apple");
        d.put("2", "Samsung");
        d.put("3", "Sony");
        d.put("4", "Nokia");
        d.put("5", "Karbon");
        d.put("6", "Micro Max");
        for (int i = 1; i <= d.size(); i++) {
            System.out.print(d.get("" + i) + ", ");
        }
    }
}


Micro Max, Karbon, Nokia, Sony, Samsung, Apple,
Apple, Samsung, Sony, Nokia, Karbon, Micro Max,
Some other output
Output can not be determined
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Dictionary Class - java.util.Dictionary

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App