Object Oriented Programming - I (3140705) MCQs

MCQs of Sets and Maps

Showing 11 to 13 out of 13 Questions
11.
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.keySet());
        }
    }
(a) [A, B, C]
(b) {A, B, C}
(c) {1, 2, 3}
(d) [1, 2, 3]
Answer:

Option (a)

12.
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.get("B"));
        }
    }
(a) 1
(b) 2
(c) 3
(d) null
Answer:

Option (b)

13.
Which of this interface must contain a unique element?
(a) Set
(b) List
(c) Array
(d) Collection
Answer:

Option (a)

Showing 11 to 13 out of 13 Questions