Is this true or false. map interface is derived from the collection interface.

In this section you can learn and practice Java Programming Questions based on "Objects and Collections" and improve your skills in order to face the interview, competitive examination and various entrance test (CAT, GATE, GRE, MAT, Bank Exam, Railway Exam etc.) with full confidence.

Where can I get Java Programming Objects and Collections questions and answers with explanation?

IndiaBIX provides you lots of fully solved Java Programming (Objects and Collections) questions and answers with Explanation. Solved examples with detailed answer description, explanation are given and it would be easy to understand. All students, freshers can download Java Programming Objects and Collections quiz questions with answers as PDF files and eBooks.

Where can I get Java Programming Objects and Collections Interview Questions and Answers (objective type, multiple choice)?

Here you can find objective type Java Programming Objects and Collections questions and answers for interview and entrance examination. Multiple choice and true or false type questions are also provided.

How to solve Java Programming Objects and Collections problems?

You can easily solve all kind of Java Programming questions based on Objects and Collections by practicing the objective type exercises given below, also get shortcut methods to solve Java Programming Objects and Collections problems.

Exercise :: Objects and Collections - General Questions

1. 

Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance?

A.TreeMapB.HashMapC.LinkedHashMapD.The answer depends on the implementation of the existing instance.

Answer: Option C

Explanation:

The iteration order of a Collection is the order in which an iterator moves through the elements of the Collection. The iteration order of a LinkedHashMap is determined by the order in which elements are inserted.

When a new LinkedHashMap is created by passing a reference to an existing Collection to the constructor of a LinkedHashMap the Collection.addAll method will ultimately be invoked.

The addAll method uses an iterator to the existing Collection to iterate through the elements of the existing Collection and add each to the instance of the new LinkedHashMap.

Since the iteration order of the LinkedHashMap is determined by the order of insertion, the iteration order of the new LinkedHashMap must be the same as the interation order of the old Collection.


2. 

Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?

A.java.lang.StringB.java.lang.DoubleC.java.lang.StringBufferD.java.lang.Character

Answer: Option C

Explanation:

java.lang.StringBuffer is the only class in the list that uses the default methods provided by class Object.

Collection Quiz in Java - MCQ - 150 Multiple choice questions in 6 sets





This Quiz consists of Collection's 150 Multiple choice questions in 6 sets - Java Collection quiz - MCQ
Contents of page >













Note : Each set consists of 25 questions
Each set consists of 5 EASY level difficulty questions 1 mark each.         1 * 5 = 5 marks
Each set consists of 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks
Each set consists of 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks
So, each Set is TOTAL of 55 marks

This quiz have been designed to check beginners and experienced Java developers skills.
Scoring below 15 marks means POOR : You are Java Beginner and need to work very hard.
Scoring 15-34 marks means AVERAGE : You know Java basics, but you need more practice.
Scoring 35-50 marks means GOOD : You have good Java knowledge.
Scoring above 50 marks means EXCELLENT : You have outstanding java knowledge.





Collection Java - MCQ set 1 (25 questions, 55 marks)



    Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks

  1. Which of these is not a interface in the Collections Framework?

  2. a.Collection
    b.Group
    c.Set
    d.List

  3. Which interface restricts duplicate elements?

  4. a.Set
    b.List
    c.Map
    d.(All of these)

  5. Which of these collection class has the ability to grow dynamically?

  6. a.Array
    b.Arrays
    c.ArrayList
    d.(None of these)

  7. The accuracy and efficiency of a HashMap can be guaranteed with:

  8. a.override equals method
    b.override hashCode method
    c.(None of these)
    d.(All of these)

  9. A HashMap allows the existence of:

  10. a.null values
    b.one null key
    c.(None of these)
    d.(All of these)



    Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks

  11. What implementation of Iterator can traverse a collection in both directions?

  12. a.Iterator
    b.ListIterator
    c.SetIterator
    d.MapIterator

  13. The Comparable interface contains which called?

  14. a.toCompare
    b.compare
    c.compareTo
    d.compareWith

  15. Which is faster and uses less memory?

  16. a.ListEnumeration
    b.Iterator
    c.Enumeration
    d.ListIterator

  17. What Iterator can throw a ConcurrentModificationException?

  18. a.Fail-fast Iterators
    b.Fail-safe Iterators
    c.(All of these)
    d.(None of these)

  19. What is the default number of Partitions/segments in Concurrent Hash Map?

  20. a.12
    b.32
    c.4
    d.16

  21. Which is best suited to a multi-threaded environment?

  22. a.WeakHashMap
    b.Hashtable
    c.HashMap
    d.ConcurrentHashMap

  23. The default capacity of a Vector is:

  24. a.10
    b.12
    c.8
    d.16

  25. Which does NOT implement the Collection interface?

  26. a.List
    b.Map
    c.Set
    d.(None of these)

  27. The default capacity of a ArrayList is:

  28. a.12
    b.16
    c.1
    d.10

  29. Which provides better performance for the insertion and removal from the middle of the list?

  30. a.Vector
    b.ArrayList
    c.LinkedList
    d.(All of these)



    Q16 - Q25, 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks

  31. What will be output of given code -

    Is this true or false. map interface is derived from the collection interface.

  32. a.compile time exception
    b.3 2 1
    c.1 2 3
    d.2 3 1

  33. What will be output of given code -

    Is this true or false. map interface is derived from the collection interface.

  34. a.1 2 3
    b.1 followed by exception
    c.Compile time exception
    d.Runtime Exception - ClassCastException

  35. What will be output of given code -

    Is this true or false. map interface is derived from the collection interface.

  36. a.a
        followed by ConcurrentModificationException
    b.a b c
    c.a b
    d.a c

  37. An unordered array has a search time complexity of:

  38. a.O(log n)
    b.O(n)
    c.O(n + 1)
    d.O(1)

  39. The add and remove methods of TreeSet have a time complexity of:

  40. a.O(n)
    b.O(n + 1)
    c.O(1)
    d.O(log n)

  41. After resizing, size of ArrayList is increased by :

  42. a.200%
    b.50%
    c.100%
    d.(None of these)

  43. After resizing, size of Vector is increased by:

  44. a.200%
    b.100%
    c.50%
    d.(None of these)

  45. What will be output of given code -

    Is this true or false. map interface is derived from the collection interface.

  46. a.will execute without any exception
    b.(None of these)
    c.compilation error
    d.Throw ConcurrentModificationException

  47. Deque and Queue are derived from:

  48. a.AbstractList
    b.Collection
    c.AbstractCollection
    d.List

  49. What will be output of given code -

    Is this true or false. map interface is derived from the collection interface.

  50. a.[name=ankit, name=brad]
    b.[name=brad, name=ankit]
    c.Runtime Exception
    d.compile time exception





Quiz 1 - Correct answers



EASY
1) b
2) a
3) c
4) d
5) d

MEDIUM
6) b
7) c
8) c
9) a
10) d
11) d
12) a
13) b
14) d
15) c

HARD
16) b
17) d
18) a
19) b
20) d
21) b
22) b
23) d
24) b
25) a






Collection Java - MCQ set 2 (25 questions, 55 marks)



    Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks

  1. What guarantees type-safety in a collection?

  2. a.Generics
    b.Abstract classes
    c.Interfaces
    d.Collection

  3. HashSet internally uses?

  4. a.Set
    b.HashMap
    c.List
    d.Collection

  5. The most used interfaces from the Collection framework are?

  6. a.List
    b.Map
    c.Set
    d.(All of these)

  7. The root interface of Java Collection framework hierarchy is -

  8. a.Collection
    b.Root
    c.Collections
    d.List/Set

  9. Which of these is synchronized?

  10. a.ArrayList
    b.LinkedList
    c.Vector
    d.(None of these)



    Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks

  11. ArrayList implements which of the following?

  12. a.List
    b.RandomAccess
    c.Cloneable
    d.(All of these)

  13. Which of these allows the storage of many null values?

  14. a.Set
    b.List
    c.(None of these)
    d.(All of these)

  15. nextIndex() and previousIndex() are methods of which interface?

  16. a.IndexIterator
    b.Iterator
    c.ListIterator
    d.NextPreviousIterator

  17. Vector extends which of these?

  18. a.ArrayList
    b.LinkedList
    c.AbstractList
    d.None

  19. LinkedList implements?

  20. a.Deque
    b.List
    c.None
    d.All

  21. In Iterator, nextElement() method of Enumeration has been changed to:

  22. a.next()
    b.getNext()
    c.returnNext()
    d.name remains same

  23. Enumeration returned by Vector is?

  24. a.fail-fast
    b.fail-safe
    c.none
  25. From Java 5 onwards, which one of these is recommended to replace Hashtable?

  26. a.ConcurrentHashMap
    b.HashMap
    c.ConcurrentHashtable
    d.None

  27. Which does not allow to store a null value?

  28. a.TreeSet
    b.LinkedHashSet
    c.HashSet
    d.None

  29. Iterator returned by Vector is?

  30. a.fail-fast
    b.fail-safe
    c.none



    Q16 - Q25, 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks

  31. What describes how well an algorithm performs in best, average or worse case scenarios?

  32. a.Big-B
    b.Big-O
    c.Big-Data
    d.Big-N

  33. An ordered array has a search time complexity of?

  34. a.O(n)
    b.O(1)
    c.O(log n)
    d.O(n-1)

  35. Which Map class must be preferred in multi-threading environment to maintain natural order of keys?

  36. a.ConcurrentHashMap
    b.ConcurrentSkipListMap
    c.ConcurrentMap
    d.all

  37. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  38. a.[null, 1]
    b.[1]
    c.[null, 1, 1, null]
    d.Runtime Exception

  39. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  40. a.{a=ferrari}
    b.{a=audi, a=ferrari}
    c.{a=audi}
    d.null

  41. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  42. a.{a=ferrari}
    b.{a=audi, a=ferrari}
    c.Runtime Exception
    d.{a=audi}

  43. TreeMap implements?

  44. a.Dictionary
    b.HashMap
    c.AbstractMap
    d.NavigableMap

  45. Which list class must be preferred in multi-threading environment, considering performance constraint

  46. a.Vector
    b.CopyOnWriteArrayList
    c.ArrayList
    d.ConcurrentArrayList

  47. Which Set class must be preferred in multi-threading environment, considering performance constraint

  48. a.HashSet
    b.ConcurrentSkipListSet
    c.LinkedHashSet
    d.CopyOnWriteArraySet

  49. Which Map class must be preferred in multi-threading environment, considering performance constraint

  50. a.Hashtable
    b.CopyOnWriteMap
    c.ConcurrentHashMap
    d.ConcurrentMap





Quiz 2 - Correct answers



EASY
1) a
2) b
3) d
4) a
5) c

MEDIUM
6) d
7) b
8) c
9) c
10) d
11) a
12) b
13) a
14) a
15) a

HARD
16) b
17) c
18) b
19) c
20) a
21) b
22) d
23) b
24) b
25) c






Collection Java - MCQ set 3 (25 questions, 55 marks)



    Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks

  1. Which allows the removal of elements from a collection?

  2. a.Enumeration
    b.Iterator
    c.Both
    d.None

  3. The Comparator interface contains the method?

  4. a.compareWith()
    b.compareTo()
    c.compare()
    d.

  5. Which of these is synchronized?

  6. a.TreeMap
    b.HashMap
    c.Hashtable
    d.All

  7. Which is more offers best performance?

  8. a.TreeMap
    b.HashMap
    c.LinkedHashMap
    d.All are equal

  9. Which of these class should be preferred to be used as a key in a HashMap?

  10. a.String
    b.Integer
    c.Double
    d.Any of these



    Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks

  11. What should we use when add and remove operations are more frequent than get operations?

  12. a.LinkedList
    b.ArrayList
    c.Vector
    d.All

  13. Iterator returned by ArrayList is?

  14. a.Fail-fast
    b.Fail-safe
    c.none

  15. Iterator returned by LinkedList is?

  16. a.Fail-fast
    b.Fail-safe
    c.none

  17. Iterator returned by CopyOnWriteArrayList is ?

  18. a.Fail-fast
    b.Fail-safe
    c.none

  19. Iterator returned by HashMap on key, value and entry is?

  20. a.Fail-fast
    b.Fail-safe
    c.none

  21. Iterator returned by Hashtable on key, value and entry is?

  22. a.Fail-fast
    b.Fail-safe
    c.none

  23. Iterator returned by ConcurrentHashMap on key, value and entry is?

  24. a.Fail-fast
    b.Fail-safe
    c.none

  25. Iterator returned by LinkedHashMap on key, value and entry is?

  26. a.Fail-fast
    b.Fail-safe
    c.none

  27. Iterator returned by TreeMap on key, value and entry is?

  28. a.Fail-fast
    b.Fail-safe
    c.none

  29. Iterator returned by ConcurrentSkipListMap on key, value and entry is?

  30. a.Fail-fast
    b.Fail-safe
    c.none



    Q16 - Q25, 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks

  31. Which Set implementation is sorted and synchronized?

  32. a.LinkedHashSet
    b.ConcurrentSkipListSet
    c.TreeSet
    d.CopyOnWriteArraySet

  33. TreeMap -

  34. a.doesn't allow null key
    b.allow many null values
    c.All
    d.None

  35. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  36. a.{11=a}
    b.{11=a, 12=b}
    c.UnsupportedOperationException
    d.Compile time exception

  37. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  38. a.Runtime Exception
    b.Compile time exception
    c.{11=a, null=c}
    d.{11=a, null=null}

  39. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  40. a.3
            null
    b.2
            null
    c.1
            null
    d.0
            null

  41. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  42. a.1
            null
    b.2
            emp1 OVERRIDDEN
    c.3
            null
    d.1
            emp1 OVERRIDDEN

  43. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  44. a.1
            emp1 OVERRIDDEN
    b.2
            emp1 OVERRIDDEN
    c.1
            null
    d.3
            null

  45. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  46. a.1
           true
           1
           [1, 3, 4]
    b.3
           true
           1
           [1, 3, 4]
    c.3
           false
           1
           [1, 3, 4]
    d.1
           false
           1
           [1, 2, 4]

  47. Which Map is synchronized?

  48. a.Hashtable
    b.ConcurrentSkipListMap
    c.ConcurrentHashMap
    d.All

  49. concurrentSkipListMap allows

  50. a.one null key
    b.many null values
    c.all
    d.none





Quiz 3 - Correct answers



EASY
1) b
2) c
3) c
4) b
5) d

MEDIUM
6) a
7) a
8) a
9) b
10) a
11) a
12) b
13) a
14) a
15) b

HARD
16) b
17) c
18) b
19) a
20) a
21) c
22) d
23) a
24) d
25) d






Collection Java - MCQ set 4 (25 questions, 55 marks)



    Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks

  1. What should we use get operations are more?

  2. a.ArrayList
    b.LinkedList
    c.Any

  3. Complexity of ArrayList get method

  4. a.O(n-1)
    b.O(n)
    c.O(1)
    d.O(2n)

  5. Which is sorted by natural order?

  6. a.LinkedHashSet
    b.TreeSet
    c.HashSet
    d.None

  7. Which of these maintains insertion order?

  8. a.List
    b.Set
    c.All
    d.None

  9. Which maintains insertion order?

  10. a.TreeSet
    b.HashSet
    c.LinkedHashSet
    d.None



    Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks

  11. In Iterator, hasMoreElements() method of Enumeration has been changed to:

  12. a.hasNextElement()
    b.isNext()
    c.hasNext()
    d.name remains same

  13. TreeSet internally uses which one to store elements?

  14. a.HashMap
    b.LinkedHashMap
    c.TreeMap
    d.None

  15. HashSet internally uses?

  16. a.HashMap
    b.LinkedHashMap
    c.TreeMap
    d.None

  17. An attempt to add null key to a TreeSet will result in:

  18. a.Will compile
    b.Compile time Exception
    c.Error
    d.Runtime - NullPointerException

  19. What is initial capacity of LinkedList?

  20. a.8
    b.10
    c.16
    d.10

  21. Enumeration returned by ArrayList is

  22. a.Fail-fast
    b.Fail-safe
    c.none

  23. LinkedHashMap allows

  24. a.one null key
    b.many null values
    c.none
    d.all

  25. Hashtable allows

  26. a.one null key
    b.many null values
    c.none
    d.all

  27. How can you sort given HashMap on basis of values

  28. a.Implement Comparator interface and override its compare method
    b.It's not possible
    c.Implement Comparator interface and override its compareTo method
    d.Implement Comparator and Comparable interface

  29. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  30. a.1
            null
    b.2
            emp1 OVERRIDDEN
    c.2
            null
    d.1
            emp1 OVERRIDDEN



    Q16 - Q25, 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks

  31. What does Collections.sort internally uses when number of elements are less than 7?

  32. a.Insertion sort
    b.Merge sort
    c.Quick sort
    d.None

  33. What does Collections.sort internally uses when number of elements are greater than 7?

  34. a.Insertion sort
    b.Merge sort
    c.Quick sort
    d.None

  35. An attempt to add null key to a TreeMap will result in:

  36. a.Compile time Exception
    b.Error
    c.Runtime - NullPointerException
    d.None

  37. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  38. a.Compile time exception
    b.1
            {null=null}
    c.2
            {11=bmw, null=fer}
    d.Runtime Exception
  39. Which of these is synchronized and doesn't allow null elements?

  40. a.Vector
    b.CopyOnWriteArraySet
    c.CopyOnWriteArrayList
    d.ConcurrentSkipListSet

  41. Which of these is synchronized and isn't sorted by natural order?

  42. a.EnumSet
    b.LinkedList
    c.ConcurrentSkipListSet
    d.Vector

  43. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  44. a.11 followed by ConcurrentModificationException
    b.11
    c.ConcurrentModificationException
    d.Compile time exception

  45. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  46. a.ind followed by NullPointerException
    b.ind followed by ConcurrentModificationException
    c.ind usa null
    d.ind usa followed by NullPointerException

  47. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  48. a.daysEnumMap.get(Days.Monday) : Day1
            daysEnumMap.containsKey(Days.Monday) : true
    b.daysEnumMap.get(Days.Monday) : Day1
            daysEnumMap.containsKey(Days.Monday) : false
    c.Runtime Exception
    d.Compile time exception

  49. In ListIterator, after a call to next() or previous(), if a call is made to set(E element) followed by add() or remove() what happens?

  50. a.compilation error
    b.UnsupportedOperationException
    c.ConcurrentModificationException
    d.none





Quiz 4 - Correct answers



EASY
1) a
2) c
3) b
4) a
5) c

MEDIUM
6) c
7) c
8) a
9) d
10) b
11) a
12) d
13) c
14) a
15) b

HARD
16) a
17) b
18) c
19) c
20) d
21) d
22) b
23) c
24) d
25) b






Collection Java - MCQ set 5 (25 questions, 55 marks)



    Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks

  1. Which interface must be implemented for sorting on basis many criterias

  2. a.Comparator
    b.Comparable
    c.Serializable
    d.None

  3. Can 2 threads on same ConcurrentHashMap object access it concurrently

  4. a.we need to add additional functionality to achieve the same.
    b.Its not possible
    c.different threads can access different segments concurrently.

  5. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  6. a.Listl=new ArrayList();
    b.Listl=new ArrayList();
    c.Listl=new ArrayList();
    d.Listl=new ArrayList();

  7. Which of these provides a get(in index) method?

  8. a.Map
    b.Set
    c.List
    d.All

  9. LinkedHashSet implements:

  10. a.Set
    b.Cloneable
    c.Serializable
    d.All



    Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks

  11. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  12. a.a
            b
            c
            followed by Exception
    b.Runtime Exception
    c.Compile time exception
    d.a
            b

  13. In WeakHashMap

  14. a.An entry are automatically removed by garbage collector
    b.Behaves normally like HashMap
    c.An entry are never removed by garbage collector
    d.None

  15. A EnumSet

  16. a.Can use enum and non enum type keys
    b.Cannot use enum type keys
    c.is specialized Set implementation for use with enum type keys only
    d.None

  17. Iterator returned by HashSet is

  18. a.Fail-fast
    b.Fail-safe
    c.none

  19. Iterator returned by CopyOnWriteArraySet is

  20. a.Fail-fast
    b.Fail-safe
    c.none

  21. Iterator returned by TreeSet is

  22. a.Fail-fast
    b.Fail-safe
    c.none

  23. Iterator returned by LinkedHashSet is

  24. a.Fail-fast
    b.Fail-safe
    c.none

  25. Iterator returned by ConcurrentSkipListSet is

  26. a.Fail-fast
    b.Fail-safe
    c.none

  27. Which List is synchronized?

  28. a.Vector
    b.CopyOnWriteArrayList
    c.All
    d.none

  29. Which Set is synchronized?

  30. a.CopyOnWriteArraySet
    b.ConcurrentSkipListSet
    c.All
    d.none



    Q16 - Q25, 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks

  31. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  32. a.a
            b
            a
            b
    b.a
            b
    c.will print a infinite times
    d.a

  33. What is significance of using instanceOf operator and getClass() in equals method

  34. a.instanceOf will return true for comparing current class with its subclass as well
    b.getClass() will return true only if exactly same class is compared
    c.getClass() will return false when compared with subclass
    d.All

  35. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  36. a.11 44
    b.Runtime Exception
    c.Compile time exception
    d.44 11

  37. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  38. a.0
            null
    b.1
            null
    c.2
            null
    d.3
            null

  39. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  40. a.Compile time exception
    b.a b c d e 1
    c.a b c d e 2
    d.e d c b a -1

  41. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  42. a.5
            is WeekDay
            is weekEnd
            true
            0
    b.2
            is WeekDay
            is weekEnd
            true
            0
    c.2
            is WeekEnd
            is weekDay
            true
            0
    d.Compile time exception

  43. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  44. a.[1, 1, 2, 3]
    b.[1, 2, 2, 3]
    c.[1, 1, 3, 2]
    d.[1, 2, 3]

  45. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  46. a.[{name=amy, id=2}, {name=sam, id=4}]
    b.Runtime Exception
    c.compile time exception
    d.[{name=sam, id=4}, {name=amy, id=2}]

  47. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  48. a.[2, 3]
    b.Runtime Exception
    c.compile time exception
    d.None

  49. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  50. a.3
    b.3.0
    c.compile time exception
    d.runtime exception





Quiz 5 - Correct answers



EASY
1) a
2) c
3) d
4) c
5) d

MEDIUM
6) d
7) a
8) c
9) a
10) b
11) a
12) a
13) b
14) c
15) c

HARD
16) c
17) d
18) b
19) d
20) d
21) a
22) c
23) d
24) c
25) c






Collection Java - MCQ set 6 (25 questions, 55 marks)



    Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks

  1. Which of these does NOT have an index based structure?

  2. a.List
    b.Set
    c.Map
    d.

  3. java.util.Collections is a:

  4. a.class
    b.interface
    c.object
    d.none

  5. Methods such as reverse, shuffle and sort are available in:

  6. a.Object
    b.Collection
    c.Collections
    d.Apache Commons Collections

  7. Which of these allows duplicate elements?

  8. a.Set
    b.List
    c.All
    d.None

  9. Which allows the storage of a null key and many null values?

  10. a.Hashtable
    b.HashMap
    c.Both
    d.None



    Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks

  11. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  12. a.1
            {null=null}
    b.2
            {null=null, 11=a}
    c.Runtime Exception
    d.Compile time exception

  13. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  14. a.1
            2
    b.1
            2
            3
    c.3
            2
            1
    d.ConcurrentModificationException

  15. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  16. a.Listl=new ArrayList>();
    b.List> l=new ArrayList>();
    c.Listl=new ArrayList();
    d.List> l=new ArrayList>();

  17. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  18. a.[a, d, b, c]
    b.[a, b, c, d]
    c.[d, a, d, c]
    d.none

  19. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  20. a.1
    b.2
    c.0
    d.4

  21. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  22. a.{11=audi, null=null}
    b.{null=null}
    c.{11=bmw, null=fer}
    d.Runtime Exception

  23. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  24. a.[]
    b.[{name=sam, id=4}, {name=amy, id=2}]
    c.[{name=amy, id=2}, {name=sam, id=4}]
    d.[null]

  25. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  26. a.1 2 1.1 2.2
    b.Runtime Exception
    c.compile time exception
    d.None

  27. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  28. a.5.0
    b.5
    c.Runtime Exception
    d.compile time exception

  29. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  30. a.3
            null
    b.1
            emp1 OVERRIDDEN
    c.2
            emp1 OVERRIDDEN
    d.3
            emp1 OVERRIDDEN



    Q16 - Q25, 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks

  31. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  32. a.[3, 2, 1]
    b.compile time exception
    c.Runtime Exception
    d.[1, 2, 3]

  33. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  34. a.[1, 2, 3]
    b.Runtime Exception - classCastException
    c.[3, 2, 1]
    d.None

  35. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  36. a.[3, 2, 1]
    b.Runtime Exception - NullPointerException
    c.[1, 2, 3]
    d.Runtime Exception - classCastException

  37. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  38. a.{4=1, 3=1, 2=1}
    b.{2=1, 3=1, 4=1}
    c.{4=1, 2=1, 3=1}
    d.compile time exception

  39. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  40. a.Runtime Exception
    b.412
    c.124
    d.421

  41. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  42. a.542
    b.245
    c.425
    d.None

  43. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  44. a.Runtime Exception - NullPointer
    b.Runtime Exception - IndexOutOfBound
    c.compile time error
    d.23

  45. What will be output of following code -

    Is this true or false. map interface is derived from the collection interface.

  46. a.IndexOutOfBoundException
    b.23
    c.compile time error
    d.NullPointerException

  47. In ConcurrentHashMap - When thread locks one segment for updation it does not block it for retrieval hence some other thread can read the same segment, but it will be able to read the data before locking?

  48. a.true
    b.false
    c.may be true/false
  49. In ConcurrentHashMap - When thread locks one segment for updation it does not allow any other thread to perform updations in same segment until lock is not released on segment

  50. a.true
    b.false
    c.may be true/false




Quiz 6 - Correct answers



EASY
1) b
2) a
3) c
4) b
5) b

MEDIUM
6) b
7) d
8) d
9) a
10) b
11) d
12) c
13) a
14) a
15) b

HARD
16) b
17) a
18) b
19) a
20) b
21) a
22) d
23) c
24) a
25) a






Labels: Core Java Exam java Java Mcq(Multiple choice questions) Java QUIZ

Is Map part of Collection interface?

The Collection is further extended by List , Queue and Set which has their different-different implementations but the unique thing notice is that the Map interface doesn't extend Collection interface.

Which statement about the Collection interface is true?

The only true statement is C), All methods defined in an interface must be implemented when used by another class.

Does Map inherit from Collection interface?

Maps in Java do not inherit from the interface "Collection" though in the most online "Tutorials" Maps are explained in the same category as Sets, Lists and Queues.

Is Map root interface of Collection?

Collection) and Map interface (java. util. Map) are the two main “root” interfaces of Java collection classes.