Object Oriented Programming - I (3140705) MCQs

MCQs of List, Stacks, Queues and Priority Queues

Showing 21 to 30 out of 40 Questions
21.
Which of these methods is used to add elements in vector at specific location?
(a) add()
(b) set()
(c) AddElement()
(d) addElement()
Answer:

Option (d)

22.
What will be the output of the following Java code?
    import java.util.*;
    class vector 
    {
        public static void main(String args[]) 
        {
            Vector obj = new Vector(4,2);
            obj.addElement(new Integer(3));
            obj.addElement(new Integer(2));
            obj.addElement(new Integer(5));
            System.out.println(obj.elementAt(1));
        }
    }
(a) 0
(b) 3
(c) 2
(d) 5
Answer:

Option (c)

23.
What will be the output of the following Java code?
    import java.util.*;
    class vector 
    {
        public static void main(String args[]) 
        {
            Vector obj = new Vector(4,2);
            obj.addElement(new Integer(3));
            obj.addElement(new Integer(2));
            obj.addElement(new Integer(5));
            System.out.println(obj.capacity());
        }
    }
(a) 2
(b) 3
(c) 4
(d) 6
Answer:

Option (c)

24.
What will be the output of the following Java code?
    import java.util.*;
    class vector 
    {
        public static void main(String args[]) 
        {
            Vector obj = new Vector(4,2);
            obj.addElement(new Integer(3));
            obj.addElement(new Integer(2));
            obj.addElement(new Integer(6));
            obj.insertElementAt(new Integer(8), 2);
            System.out.println(obj);
        }
    }
(a) [3, 2, 6]
(b) [3, 2, 8]
(c) [3, 2, 6, 8]
(d) [3, 2, 8, 6]
Answer:

Option (d)

25.
What will be the output of the following Java code?
    import java.util.*;
    class vector 
    {
        public static void main(String args[]) 
        {
            Vector obj = new Vector(4,2);
            obj.addElement(new Integer(3));
            obj.addElement(new Integer(2));
            obj.addElement(new Integer(5));
            obj.removeAll(obj);
            System.out.println(obj.isEmpty());
        }
    }
(a) 0
(b) 1
(c) TRUE
(d) FALSE
Answer:

Option (c)

26.
What will be the output of the following Java code?
    import java.util.*;
    class stack 
    {
        public static void main(String args[]) 
        {
            Stack obj = new Stack();
            obj.push(new Integer(3));
            obj.push(new Integer(2));
            obj.pop();
            obj.push(new Integer(5));
     	    System.out.println(obj);
        }
    }
(a) [3, 5]
(b) [3, 2]
(c) [3, 2, 5]
(d) [3, 5, 2]
Answer:

Option (a)

27.
Which of these interface declares core method that all collections will have?
(a) set
(b) EventListner
(c) Comparator
(d) Collection
Answer:

Option (d)

28.
Which of these interface handle sequences?
(a) Set
(b) List
(c) Comparator
(d) Collection
Answer:

Option (b)

29.
Which of these is a basic interface that all other interface inherits?
(a) Set
(b) Array
(c) List
(d) Collection
Answer:

Option (d)

30.
Which of these is static variable defined in Collections?
(a) EMPTY_SET
(b) EMPTY_LIST
(c) EMPTY_MAP
(d) All of the mentioned
Answer:

Option (d)

Showing 21 to 30 out of 40 Questions