FUNDAMENTALS OF COMPUTER

DATABASE FUNDAMENTALS

BASICS OF BIG DATA

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What will be the output of the following class?import java.util.*;class A{public static void main(String[] args){HashSet<String> set=new HashSet<String>();set.add(null);set.add("One");for(String s:set)System.out.println(s);}}
A
NullPointerException
B
null, One
C
One
D
None of the above
Explanation: 

Detailed explanation-1: -HashSet is a class that extends AbstractSet and implements the Set interface in Java. It is a very useful tool that allows you to store unique items and access them in constant time (on average). No duplicate values are stored.

Detailed explanation-2: -A Set is a generic set of values with no duplicate elements. A TreeSet is a set where the elements are sorted. A HashSet is a set where the elements are not sorted or ordered. It is faster than a TreeSet.

Detailed explanation-3: -HashSet extends AbstractSet and implements the Set interface. It creates a collection that uses a hash table for storage. A hash table stores information by using a mechanism called hashing.

There is 1 question to complete.