Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class UsingTreeSet {
    public static void main(String[] args) {
        TreeSet tree = new TreeSet();
        tree.add("Roots");
        tree.add("Stem");
        tree.add("Branch");
        tree.add("Leaves");
        tree.remove("fruits");
        System.out.println("Elements in the tree are : " + tree);
    }
}


Elements in the tree are : [Branch, Leaves, Roots, Stem]
Elements in the tree are : [Roots, Stem, Branch, Leaves]
Elements in the tree are : [Branch, fruits, Leaves, Roots, Stem]
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java TreeSet - TreeSet Examples 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