1.

What Is The Output Of This Program? 1. Import Java.util.*; 2. Class Output { 3. Public Static Void Main(string Args[]) { 4. Hashset Obj = New Hashset(); 5. Obj.add("a"); 6. Obj.add("b"); 7. Obj.add("c"); 8. System.out.println(obj + " " + Obj.size()); 9. } 10. }

Answer»

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

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



Discussion

No Comment Found

Related InterviewSolutions