You are on page 1of 5

NPTEL Online Certification Courses

Indian Institute of Technology Kharagpur

DATA STRUCTURES AND ALGORITHMS USING JAVA


Assignment 2
Java Collection Framework
TYPE OF QUESTION: MCQ
Number of questions: 10 Total marks: 10× 1 = 10
______________________________________________________________________________

QUESTION 1:
Which of the following is/are FALSE in the case of Data Structure in Java?

a. Array is an indexed linear data structure


b. linked list is a sequential non-linear data structure
c. stack and queue are Linear data structure
d. set, tree, table, and graph are Non-linear data structure
Correct Answer: b

Detailed Solution:
Option b is wrong. A linked list is a linear data structure.
The correct statement will be: Linked List is a sequential linear data structure.
All other options are correct.
● Array, linked list, stack, and queue are linear data structures.
● Array is an indexed data structure.
● Linked list is a sequential data structure.
● Set, tress, table, and graph are non-linear data structures.

For more details, refer to slide #6 from week 2, titled Differential data structure.
____________________________________________________________________________

QUESTION 2:
Which of the following is True in the case of Java Collection Framework(JCF)?

a. JCF provides mid-performance software encoding


b. Extending and/or adapting a collection is easy and not flexible with JCF
c. The JCF is consist of : Collections and Facilities
d. The JCF doesn’t allow different types of collections to work with a high degree of
interoperability.

Correct Answer: C
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

Detailed Solution:
Only option C is true; all other options are false.
The correct statements will be as follows:
● JCF provides high-performance software encoding
● Extending and /or adapting a collection is easy and flexible
● The JCF consists of : Collections under Collection and Facilities under Map(from slide)
● JCF allows different types of collections to work with a high degree of interoperability

for more details refer to lecture slides.

QUESTION 3:
Which among the following is a Java Collection Framework(JCF) Class?

a. Set
b. List
c. Queue
d. Vector

Correct Answer: d

Detailed Solution:
The entire Java Collection Framework (JCF) is built upon a set of standard interfaces, classes, and
algorithms.
● Interfaces: Set, List, Queue, Deque
● Classes: Array List, Vector, LinkedList, PriorityQueue, HashSet, Linked HashSet,
TreeSet

As Vector lies under JCF classes, hence d is the correct answer here.

QUESTION 4:
Choose the right option to complete the following sentence in the case of EnumSet

EnumSet extends AbstractSet and implements ______.

a. Enum type
b. Enum
c. AbstractSet
d. Set
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

Correct Answer: d

Detailed Solution:
EnumSet extends AbstractSet and implement Set.
Refer to slide #83 titled ‘Class EnumSet’.

QUESTION 5:
Which of the following statement is incorrect with respect to ‘Map’ in Java?

a. A Map is an object that maps keys to values


b. Map is a collection of key-value pairs.
c. Map is a generic interface that has the declaration: interface Map <T>
d. SortedMap interface doesn’t extend Map.

Correct Answer: d

Detailed Solution:
All are true except option d.
SortedMap interface extends Map

For further explanation refer to slide #105 #108 #115

QUESTION 6:
Which of the following statements is/are incorrect for Java Collection Framework (JCF)?

a. Vector is similar to. ArrayList, which represents a dynamic array


b. Stack is a subclass of Vector that implements a standard last-in,first-out stack.
c. Unlike HashMap, Hashtable doesn’t store Key/value pairs.
d. Class Properties are used to maintain a list of values in which both key and value are
String.

Correct Answer: C

Detailed Solution:
Statement C is incorrect ther correct statement will be
“Like Hashmap, hashtable also stores Key/Value pairs.”

QUESTION 7:
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

In Java Collection Framework(JCF) Dictionary is ________?

a. A concrete implementation
b. An interface
c. An abstract class
d. A data structure for storing only integers

Correct Answer: c

Detailed Solution:
In the Java Collection Framework (JCF), a Dictionary is an abstract class. The Dictionary class
was part of the original collection classes introduced in Java, which served as the basis for the
modern Map interface. It maps keys to values, but it is now considered obsolete and has been
replaced by the Map interface.

QUESTION 8:
Which of the following interface(s) is (are) NOT descendant(s) of java.util.Collection?
a. java.util.SortedMap
b. java.util.Set
c. java.util.SortedSet
d. java.util.Queue
Correct Answer: a

Detailed Solution:
java.util.SortedMap is a descendant of java.util.Map

QUESTION 9:
Which of the following declaration(s) is(are) not correct to instantiate a collection object?
a. List <data-type> list1= new ArrayList();
b. List <data-type> list2 = new LinkedList();
c. List <data-type> list3 = new Vector();
d. List <data-type> list4 = new PriorityQueue() ;
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

Correct Answer: d

Detailed Solution:
Option(d):
Queue<String> q1 = new PriorityQueue();

QUESTION 10:
Which of these interface handle sequences?
a. Set
b. Array
c. List
d. Collection

Correct Answer: c

Detailed Solution:
List interface handles sequences.

************END************

You might also like