1. |
Which of these classes implements Set interface?
|
||||||||
Answer:
Option (b) |
2. |
Which of these method of HashSet class is used to add elements to its object?
|
||||||||
Answer:
Option (a) |
3. |
What will be the output of the following Java program?
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()); } }
|
||||||||
Answer:
Option (b) |
4. |
Which of these object stores association between keys and values?
|
||||||||
Answer:
Option (b) |
5. |
Which of these classes provide implementation of map interface?
|
||||||||
Answer:
Option (b) |
6. |
Which of these method is used to remove all keys/values pair from the invoking map?
|
||||||||
Answer:
Option (b) |
7. |
Which of these method Map class is used to obtain an element in the map having specified key?
|
||||||||
Answer:
Option (b) |
8. |
Which of these methods can be used to obtain set of all keys in a map?
|
||||||||
Answer:
Option (d) |
9. |
Which of these method is used add an element and corresponding key to a map?
|
||||||||
Answer:
Option (a) |
10. |
What will be the output of the following Java program?
import java.util.*; class Maps { public static void main(String args[]) { HashMap obj = new HashMap(); obj.put("A", new Integer(1)); obj.put("B", new Integer(2)); obj.put("C", new Integer(3)); System.out.println(obj); } }
|
||||||||
Answer:
Option (d) |