Multiple choice technology programming languages

1.Set s = new TreeSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

This is a duplicate of blocks 129672, 129674, 129675, and 129676. TreeSet uses natural ordering; when you add Integer after String, it attempts to compare them and throws ClassCastException because Integer and String are not mutually comparable.