Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Freq {
    public static void main(String args[]) {
        TreeSet str = new TreeSet();
        for (int key = 1; key < 4; key++)
            for (int value = 1; value < 4; value++)
                ((Map) str).put((key * key - key), value);
        System.out.println(str);
    }
}


[1, 2, 3]
[0, 2, 6]
{0=3, 2=3, 6=3}
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Collection Framework In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App