1. Which allows the removal of elements from a collection? |
---|
1. Iterator |
2. Enumeration |
3. Both |
4. None |
Answer: 1 |
2. Which of these is not a interface in the Collections Framework? |
---|
1. Collection |
2. Set |
3. Group |
4. List |
Answer: 3 |
3. What implementation of Iterator can traverse a collection in both directions? |
---|
1. Iterator |
2. ListIterator |
3. SetIterator |
4. MapIterator |
Answer: 2 |
4. which Map class must be preferred in multi-threading environment to maintain natural order of keys? |
---|
1. ConcurrentHashMap |
2. ConcurrentSkipListMap |
3. ConcurrentMap |
4. All |
Answer: 2 |
5. What does Collections.sort internally uses when number of elements are greater than 7? |
---|
1. Insertion sort |
2. Merge sort |
3. Quick sort |
4. None |
Answer: 2 |
6. An attempt to add null key to a TreeMap will result in: |
---|
1. Compile time Exception |
2. Error |
3. Runtime - NullPointerException |
4. None |
Answer: 3 |
7. Which of these is synchronized and doesn't allow null elements? |
---|
1. Vector |
2. CopyOnWriteArraySet |
3. CopyOnWriteArrayList |
4. ConcurrentSkipListSet |
Answer: 4 |
8. Which of these collection class has the ability to grow dynamically? |
---|
1. Array |
2. Arrays |
3. ArrayList |
4. None of These |
Answer: 3 |
9. nextIndex() and previousIndex() are methods of which interface? |
---|
1. IndexIterator |
2. Iterator |
3. ListIterator |
4. NextPreviousIterator |
Answer: 3 |
10. Which of these packages contain all the collection classes? |
---|
1. java.lang |
2. java.util |
3. java.net |
4. java.awt |
Answer: 2 |
11. What is Collection in Java? |
---|
1. A group of objects |
2. A group of classes |
3. A group of interfaces |
4. None of the mentioned |
Answer: 1 |
12. Which of these methods deletes all the elements from invoking collection? |
---|
1. clear() |
2. reset() |
3. delete() |
4. refresh() |
Answer: 1 |
13. Which interface provides the capability to store objects using a key-value pair? |
---|
1. Java.util.Map |
2. Java.util.Set |
3. Java.util.List |
4. Java.util.Collection |
Answer: 1 |
14. Which of these interface handle sequences? |
---|
1. Set |
2. List |
3. Comparator |
4. Collection |
Answer: 2 |
15. Which of these is static variable defined in Collections? |
---|
1. EMPTY_SET |
2. EMPTY_LIST |
3. EMPTY_MAP |
4. All of the mentioned |
Answer: 4 |
16. Which of these class is superclass of every class in Java? |
---|
1. String class |
2. Object class |
3. Abstract class |
4. ArrayList class |
Answer: 2 |
17. The methods defined by Thread class that help to manage thread are? |
---|
1. joined |
2. stop |
3. getname |
4. all of the above |
Answer: 4 |
18. Which of the following method is used to initialize the instance variable of a class |
---|
1. class |
2. public |
3. constructor |
4. Destructor |
Answer: 3 |
19. A top level class may have which one of the following access modifiers? |
---|
1. package |
2. private |
3. protected |
4. public |
Answer: 4 |
20. A subclass is also called as? |
---|
1. inner class |
2. nested class |
3. derived class |
4. hidden class |
Answer: 3 |
ALSO, SEE JAVA MCQ
Java Multiple Choice Questions
java mcq questions with answers pdf
50+ Java MCQ along with Answers
AVA programming mcq questions and answers