Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Answers MCQ

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

1 A queue follows __________

a) FIFO (First In First Out) principle


b) LIFO (Last In First Out) principle
c) Ordered array
d) Linear tree

2 A data structure in which elements can be inserted or deleted at/from both ends but not in
the middle is?
a) Queue
b) Circular queue
c) Dequeue
d) Priority queue

3 The type of expression in which operator succeeds its operands is?

a) Infix Expression

b) Prefix Expression

c) Postfix Expression

d) Both Prefix and Postfix Expressions

4 Which of the following is not an inherent application of stack?

a) Reversing a string

b) Evaluation of postfix expression

c) Implementation of recursion

d) Job scheduling

5 Which of the following statement(s) about stack data structure is/are NOT correct?
a) Linked List are used for implementing Stacks

b) Top of the Stack always contain the new node

c) Stack is the FIFO data structure

d) Null link is present in the last node at the bottom of the stack

6 A normal queue, if implemented using an array of size MAX_SIZE, gets full when?
a) Rear = MAX_SIZE – 1
b) Front = (rear + 1)mod MAX_SIZE
c) Front = rear + 1
d) Rear = front

7 Map implements collection interface?

a) True

b) False

8 If the size of the array used to implement a circular queue is MAX_SIZE. How rear moves to
traverse inorder to insert an element in the queue?
a) rear=(rear%1)+MAX_SIZE
b) rear=(rear+1)%MAX_SIZE
c) rear=rear+(1%MAX_SIZE)
d) rear=rear%(MAX_SIZE+1)

9 What is the difference between Queue and Stack?


a) Stack is LIFO; Queue is FIFO
b) Queue is LIFO; Stack is FIFO
c) Stack and Queue is FIFO
d) Stack and Queue is LIFO
10 Which of the following is not the type of queue?
a) Ordinary queue
b) Single ended queue
c) Circular queue
d) Priority queue

11 Which of the below does not implement Map interface?

a) HashMap

b) Hashtable

c) EnumMap

d) Vector

12 What is the premise of equality for IdentityHashMap?

a) Reference equality

b) Name equality

c) Hashcode equality

d) Length equality

13 What happens if we put a key object in a HashMap which exists?

a) The new object replaces the older object

b) The new object is discarded

c) The old object is removed from the map

d) It throws an exception as the key already exists in the map

14 ………. is putting an element in the appropriate place in a sorted list yields a larger sorted
order list.
A. Insertion

B. Extraction

C. Selection

D. Distribution

15 . What happens if we put a key object in a HashMap which exists?

a) The new object replaces the older object

b) The new object is discarded

c) The old object is removed from the map

d) It throws an exception as the key already exists in the map

16 If large number of items are stored in hash bucket, what happens to the internal structure?

a) The bucket will switch from LinkedList to BalancedTree

b) The bucket will increase its size by a factor of load size defined

c) The LinkedList will be replaced by another hashmap

d) Any further addition throws Overflow exception

17 What is difference between dequeue() and peek() function of java?


a) dequeue() and peek() remove and return the next time in line
b) dequeue() and peek() return the next item in line
c) dequeue() removes and returns the next item in line while peek() returns the next item in
line
d) peek() removes and returns the next item in line while dequeue() returns the next item in
line

18 What is the correct method used to insert and delete items from the queue?
a) push and pop
b) enqueue and dequeue
c) enqueue and peek
d) add and remove

19 Is hashmap an ordered collection.

a) True

b) False

20 Where does a new element be inserted in linked list implementation of a queue?


a) Head of list
b) Tail of list
c) At the centre of list
d) All the old entries are pushed and then the new element is inserted

21 While finding the correct location for saving key value pair, how many times the key is
hashed?

a) 1

b) 2

c) 3

d) unlimited till bucket is found

22 What does Collections.emptySet() return?

a. Immutable Set

b. Mutable Set

c. The type of Set depends on the parameter passed to the emptySet() method

d. Null object
23 What is the relation between hashset and hashmap?

a. HashSet internally implements HashMap

b. HashMap internally implements HashSet

c. HashMap is the interface; HashSet is the concrete class

d. HashSet is the interface; HashMap is the concrete class

You might also like