πŸ“Š JAVA
Q. What will be the output of given code
Code:
import java.util.HashSet;
import java.util.Set;
public class HashSetTest
{
public static void main (String args[])
{
Set hashSet = new HashSet();
hashSet.add(“1”);
hashSet.add(1);
hashSet.add(null);
hashSet.add(“null”);
System.out.println(hashSet);
}

}
  • (A) [null, 1]
  • (B) [1]
  • (C) [null, 1, 1, null]
  • (D) Runtime exception
πŸ’¬ Discuss
βœ… Correct Answer: (C) [null, 1, 1, null]

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
286
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Tina Singh
Publisher
πŸ“ˆ
91%
Success Rate