import java.util.*; class Output { public static void main(String args[]) { HashSet obj = new HashSet(); obj.add("A"); obj.add("B"); obj.add("C"); System.out.println(obj + " " + obj.size()); } }
a) ABC 3
b) [A, B, C] 3
c) ABC 2
d) [A, B, C] 2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
b
Explanation: HashSet obj creates an hash object which implements Set interface, obj.size() gives the number of elements stored in the object obj which in this case is 3.
Output:
$ javac Output.java
$ java Output
[A, B, C] 3