Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Cloning {
    public static void main(String[] args) {
        TreeSet tree = new TreeSet();
        tree.add("Roots");
        tree.add("Stem");
        tree.add("Branchs");
        TreeSet newtree = (TreeSet) tree.clone();
        newtree.add("Leaves");
        System.out.println(newtree);
    }
}


[Roots, Stem, Branchs, Leaves]
[Branchs, Leaves, Roots, Stem]
[Roots, Stem, Branchs]
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