Object Oriented Programming - I (3140705) MCQs

MCQs of List, Stacks, Queues and Priority Queues

Showing 11 to 20 out of 40 Questions
11.
Which of these standard collection classes implements a linked list data structure?
(a) AbstractList
(b) LinkedList
(c) HashSet
(d) AbstractSet
Answer:

Option (b)

12.
Which of these method is used to add an element to the start of a LinkedList object?
(a) add()
(b) first()
(c) AddFirst()
(d) addFirst()
Answer:

Option (d)

13.
Which of these methods can be used to delete the last element in a LinkedList object?
(a) remove()
(b) delete()
(c) removeLast()
(d) deleteLast()
Answer:

Option (c)

14.
Which of this method is used to change an element in a LinkedList Object?
(a) change()
(b) set()
(c) redo()
(d) add()
Answer:

Option (b)

15.
What will be the output of the following Java code snippet?
    import java.util.*;
    class Linkedlist 
    {
        public static void main(String args[]) 
        {
            LinkedList obj = new LinkedList();
            obj.add("A");
            obj.add("B");
            obj.add("C");
            obj.addFirst("D");
            System.out.println(obj);
        }
    }
(a) [A, B, C]
(b) [D, B, C]
(c) [A, B, C, D]
(d) [D, A, B, C]
Answer:

Option (d)

16.
What will be the output of the following Java program?
    import java.util.*;
    class Linkedlist 
    {
        public static void main(String args[]) 
        {
            LinkedList obj = new LinkedList();
            obj.add("A");
            obj.add("B");
            obj.add("C");
            obj.removeFirst();
            System.out.println(obj);
        }
    }
(a) [A, B]
(b) [B, C]
(c) [A, B, C, D]
(d) [A, B, C]
Answer:

Option (b)

17.
Which of these class object can be used to form a dynamic array?
(a) ArrayList
(b) Map
(c) Vector
(d) ArrayList & Vector
Answer:

Option (d)

18.
Which of these are legacy classes?
(a) Stack
(b) Hashtable
(c) Vector
(d) All of the mentioned
Answer:

Option (d)

19.
Which of these is the interface of legacy?
(a) Map
(b) Enumeration
(c) HashMap
(d) Hashtable
Answer:

Option (b)

20.
What is the name of a data member of class Vector which is used to store a number of elements in the vector?
(a) length
(b) elements
(c) elementCount
(d) capacity
Answer:

Option (c)

Showing 11 to 20 out of 40 Questions