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. Show
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 Questions1. 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.CharacterAnswer: 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
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. Collection Java - MCQ set 1 (25 questions, 55 marks)
Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks a.Collection b.Group c.Set d.List a.Set b.List c.Map d.(All of these) a.Array b.Arrays c.ArrayList d.(None of these) a.override equals method b.override hashCode method c.(None of these) d.(All of these) 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 a.Iterator b.ListIterator c.SetIterator d.MapIterator a.toCompare b.compare c.compareTo d.compareWith a.ListEnumeration b.Iterator c.Enumeration d.ListIterator a.Fail-fast Iterators b.Fail-safe Iterators c.(All of these) d.(None of these) a.12 b.32 c.4 d.16 a.WeakHashMap b.Hashtable c.HashMap d.ConcurrentHashMap a.10 b.12 c.8 d.16 a.List b.Map c.Set d.(None of these) a.12 b.16 c.1 d.10 a.Vector b.ArrayList c.LinkedList d.(All of these) Q16 - Q25, 10 HARD level difficulty questions 3 mark each. 3 * 10 = 30 marks a.compile time exception b.3 2 1 c.1 2 3 d.2 3 1 a.1 2 3 b.1 followed by exception c.Compile time exception d.Runtime Exception - ClassCastException a.a followed by ConcurrentModificationException b.a b c c.a b d.a c a.O(log n) b.O(n) c.O(n + 1) d.O(1) a.O(n) b.O(n + 1) c.O(1) d.O(log n) a.200% b.50% c.100% d.(None of these) a.200% b.100% c.50% d.(None of these) a.will execute without any exception b.(None of these) c.compilation error d.Throw ConcurrentModificationException a.AbstractList b.Collection c.AbstractCollection d.List a.[name=ankit, name=brad] b.[name=brad, name=ankit] c.Runtime Exception d.compile time exception Quiz 1 - Correct answersEASY 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 a.Generics b.Abstract classes c.Interfaces d.Collection a.Set b.HashMap c.List d.Collection a.List b.Map c.Set d.(All of these) a.Collection b.Root c.Collections d.List/Set a.ArrayList b.LinkedList c.Vector d.(None of these) Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks a.List b.RandomAccess c.Cloneable d.(All of these) a.Set b.List c.(None of these) d.(All of these) a.IndexIterator b.Iterator c.ListIterator d.NextPreviousIterator a.ArrayList b.LinkedList c.AbstractList d.None a.Deque b.List c.None d.All a.next() b.getNext() c.returnNext() d.name remains same a.fail-fast b.fail-safe c.none a.ConcurrentHashMap b.HashMap c.ConcurrentHashtable d.None a.TreeSet b.LinkedHashSet c.HashSet d.None a.fail-fast b.fail-safe c.none Q16 - Q25, 10 HARD level difficulty questions 3 mark each. 3 * 10 = 30 marks a.Big-B b.Big-O c.Big-Data d.Big-N a.O(n) b.O(1) c.O(log n) d.O(n-1) a.ConcurrentHashMap b.ConcurrentSkipListMap c.ConcurrentMap d.all a.[null, 1] b.[1] c.[null, 1, 1, null] d.Runtime Exception a.{a=ferrari} b.{a=audi, a=ferrari} c.{a=audi} d.null a.{a=ferrari} b.{a=audi, a=ferrari} c.Runtime Exception d.{a=audi} a.Dictionary b.HashMap c.AbstractMap d.NavigableMap a.Vector b.CopyOnWriteArrayList c.ArrayList d.ConcurrentArrayList a.HashSet b.ConcurrentSkipListSet c.LinkedHashSet d.CopyOnWriteArraySet a.Hashtable b.CopyOnWriteMap c.ConcurrentHashMap d.ConcurrentMap Quiz 2 - Correct answersEASY 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 a.Enumeration b.Iterator c.Both d.None a.compareWith() b.compareTo() c.compare() d. a.TreeMap b.HashMap c.Hashtable d.All a.TreeMap b.HashMap c.LinkedHashMap d.All are equal a.String b.Integer c.Double d.Any of these Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks a.LinkedList b.ArrayList c.Vector d.All a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none Q16 - Q25, 10 HARD level difficulty questions 3 mark each. 3 * 10 = 30 marks a.LinkedHashSet b.ConcurrentSkipListSet c.TreeSet d.CopyOnWriteArraySet a.doesn't allow null key b.allow many null values c.All d.None a.{11=a} b.{11=a, 12=b} c.UnsupportedOperationException d.Compile time exception a.Runtime Exception b.Compile time exception c.{11=a, null=c} d.{11=a, null=null} a.3 null b.2 null c.1 null d.0 null a.1 null b.2 emp1 OVERRIDDEN c.3 null d.1 emp1 OVERRIDDEN a.1 emp1 OVERRIDDEN b.2 emp1 OVERRIDDEN c.1 null d.3 null 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] a.Hashtable b.ConcurrentSkipListMap c.ConcurrentHashMap d.All a.one null key b.many null values c.all d.none Quiz 3 - Correct answersEASY 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 a.ArrayList b.LinkedList c.Any a.O(n-1) b.O(n) c.O(1) d.O(2n) a.LinkedHashSet b.TreeSet c.HashSet d.None a.List b.Set c.All d.None a.TreeSet b.HashSet c.LinkedHashSet d.None Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks a.hasNextElement() b.isNext() c.hasNext() d.name remains same a.HashMap b.LinkedHashMap c.TreeMap d.None a.HashMap b.LinkedHashMap c.TreeMap d.None a.Will compile b.Compile time Exception c.Error d.Runtime - NullPointerException a.8 b.10 c.16 d.10 a.Fail-fast b.Fail-safe c.none a.one null key b.many null values c.none d.all a.one null key b.many null values c.none d.all 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 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 a.Insertion sort b.Merge sort c.Quick sort d.None a.Insertion sort b.Merge sort c.Quick sort d.None a.Compile time Exception b.Error c.Runtime - NullPointerException d.None a.Compile time exception b.1 {null=null} c.2 {11=bmw, null=fer} d.Runtime Exception a.Vector b.CopyOnWriteArraySet c.CopyOnWriteArrayList d.ConcurrentSkipListSet a.EnumSet b.LinkedList c.ConcurrentSkipListSet d.Vector a.11 followed by ConcurrentModificationException b.11 c.ConcurrentModificationException d.Compile time exception a.ind followed by NullPointerException b.ind followed by ConcurrentModificationException c.ind usa null d.ind usa followed by NullPointerException 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 a.compilation error b.UnsupportedOperationException c.ConcurrentModificationException d.none Quiz 4 - Correct answersEASY 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 a.Comparator b.Comparable c.Serializable d.None a.we need to add additional functionality to achieve the same. b.Its not possible c.different threads can access different segments concurrently. a.Listl=new ArrayList(); b.Listl=new ArrayList(); c.Listl=new ArrayList(); d.Listl=new ArrayList(); a.Map b.Set c.List d.All a.Set b.Cloneable c.Serializable d.All Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks a.a b c followed by Exception b.Runtime Exception c.Compile time exception d.a b 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 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 a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Fail-fast b.Fail-safe c.none a.Vector b.CopyOnWriteArrayList c.All d.none a.CopyOnWriteArraySet b.ConcurrentSkipListSet c.All d.none Q16 - Q25, 10 HARD level difficulty questions 3 mark each. 3 * 10 = 30 marks a.a b a b b.a b c.will print a infinite times d.a 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 a.11 44 b.Runtime Exception c.Compile time exception d.44 11 a.0 null b.1 null c.2 null d.3 null 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 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 a.[1, 1, 2, 3] b.[1, 2, 2, 3] c.[1, 1, 3, 2] d.[1, 2, 3] 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}] a.[2, 3] b.Runtime Exception c.compile time exception d.None a.3 b.3.0 c.compile time exception d.runtime exception Quiz 5 - Correct answersEASY 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 a.List b.Set c.Map d. a.class b.interface c.object d.none a.Object b.Collection c.Collections d.Apache Commons Collections a.Set b.List c.All d.None a.Hashtable b.HashMap c.Both d.None Q6 - Q15, 10 MEDIUM level difficulty questions 2 mark each. 2 * 10 = 20 marks a.1 {null=null} b.2 {null=null, 11=a} c.Runtime Exception d.Compile time exception a.1 2 b.1 2 3 c.3 2 1 d.ConcurrentModificationException a.Listl=new ArrayList>(); b.List> l=new ArrayList>(); c.Listl=new ArrayList(); d.List> l=new ArrayList>(); a.[a, d, b, c] b.[a, b, c, d] c.[d, a, d, c] d.none a.1 b.2 c.0 d.4 a.{11=audi, null=null} b.{null=null} c.{11=bmw, null=fer} d.Runtime Exception a.[] b.[{name=sam, id=4}, {name=amy, id=2}] c.[{name=amy, id=2}, {name=sam, id=4}] d.[null] a.1 2 1.1 2.2 b.Runtime Exception c.compile time exception d.None a.5.0 b.5 c.Runtime Exception d.compile time exception 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 a.[3, 2, 1] b.compile time exception c.Runtime Exception d.[1, 2, 3] a.[1, 2, 3] b.Runtime Exception - classCastException c.[3, 2, 1] d.None a.[3, 2, 1] b.Runtime Exception - NullPointerException c.[1, 2, 3] d.Runtime Exception - classCastException 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 a.Runtime Exception b.412 c.124 d.421 a.542 b.245 c.425 d.None a.Runtime Exception - NullPointer b.Runtime Exception - IndexOutOfBound c.compile time error d.23 a.IndexOutOfBoundException b.23 c.compile time error d.NullPointerException a.true b.false c.may be true/false a.true b.false c.may be true/false Quiz 6 - Correct answersEASY 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.
|