Interview Questions and Answers - Order By Newest Very Frequently asked. Favorite question in walkins and telephonic interviews. Usually among first few questions. Asked in different variants. Must know for intermediate and expert professionals.Among Top 10 frequently asked questions. Q61. What is rule regarding overriding equals and hashCode method ? Core Java
Ans. A Class must override the hashCode method if its overriding the equals method. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   hashcode  hash code   equals   collections Asked in 44 Companies intermediate   frequent Try 1 Question(s) Test Q62. What is the difference between Collection and Collections ? Core Java
Ans. Collection is an interface whereas Collections is a utility class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections Asked in 1 Companies Q63. How can we reverse the order in the TreeMap ?
Ans. Using Collections.reverseOrder() Map tree = new TreeMap(Collections.reverseOrder()); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map   treemap Try 1 Question(s) Test Q64. TreeMap orders the elements on which field ?
Ans. Keys Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map   treemap Q65. How TreeMap orders the elements if the Key is a String ?
Ans. As String implements Comparable, It refers to the String compareTo method to identify the order relationship among those elements. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   comparable interface   treemap   compareto Q66. Can we add heterogeneous elements into TreeMap ?
Ans. No, Sorted collections don't allow addition of heterogeneous elements as they are not comparable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   comparable interface   treemap Q67. Will it create any problem if We add elements with key as user defined object into the TreeMap ?
Ans. It won't create any problem if the objects are comparable i.e we have that class implementing Comparable interface. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap   comparable interface Q68. Can we have null keys in TreeMap ? Core Java
Ans. No, results in exception. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap Asked in 6 Companies Basic   frequent Ans. Yes. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap   yes-no Q70. Which interface TreeMap implements ?
Ans. TreeMap implements NavigableMap, SortedMap, Serializable and Clonable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap Q71. What will be the output of this code ? Set mySet = new TreeSet(); mySet.add("4567"); mySet.add("5678"); mySet.add("6789"); for(String s: mySet){ System.out.println(s); }
Ans. 4567 5678 6789 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   set   treeset   coding   code Q72. public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } public class Test { Set mySet = new HashSet(); mySet.add(Day.MONDAY); mySet.add(Day.SUNDAY); mySet.add(Day.SATURDAY); for(Day d: mySet){ System.out.println(d); } }
Ans. SUNDAY MONDAY SATURDAY Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  enum   set   collections   hashset   coding   code Try 3 Question(s) Test Q73. How is HashSet maintained in memory by Java ? Core Java
Ans. HashSet is maintained as HashMap by Java with values of the HashSet as Keys of the HashMap and value of the HashMap as the constant PRESENT. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ebay  java   collections   hashset   hashmap expert Q74. What is ConcurrentLinkedDeque ? Core Java
Ans. It's a Collections concrete class that provides implementation of a Double Ended queue that allows concurrent insertion, removal, and access operations that can be executed safely across multiple threads. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   queue   deque   concurrent collections Q75. What is CopyOnWriteArrayList ?
Ans. Its a type of ArrayList in which all Write operations , i.e add and set are performed by creating a new copy. This array never changes during the lifetime of the iterator, so it never throws ConcurrentModificationException Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   list   arraylist   copyonwritearraylist   ConcurrentModificationException Asked in 1 Companies Q76. What are the advantages and disadvantages of CopyOnWriteArrayList ? Core Java
Ans. This collections class has been implemented in such a manner that it can never throw ConcurrentModificationException. As it performs update and write operations by creating a new copy of ArrayList, It's slower compared to ArrayList. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   list   arraylist   copyonwritearraylist   advantages-disadvantages   ConcurrentModificationException Asked in 4 Companies Expert Q77. Name few Concurrent Collection Classes ?
Ans. ConcurrentHashMap ConcurrentLinkedDeque ConcurrentLinkedQueue ConcurrentMap ConcurrentNavigableMap ConcurrentSkipListMap ConcurrentSkipListSet Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   concurrent collections Q78. Name few Collections Map implementations ?
Ans. AbstractMap ConcurrentHashMap ConcurrentSkipListMap EnumMap HashMap IdentityHashMap LinkedHashMap SystemFlavorMap TreeMap WeakHashMap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map Q79. Name few interfaces that extends Collection Interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-interfaces-that.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   collection interface Q80. Name few classes that extends Collections class ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-inherit.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   collections class Q81. Name few abstract classes of Java collections framework ?
Ans. http://www.buggybread.com/2015/02/java-collections-abstract-classes.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections Q82. Name few classes that implement Set interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_78.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   set Q83. Name few classes that implement iterable interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_45.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   iterable Q84. Name few classes that implement Map interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_82.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map Q85. Name few classes that implement List interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_35.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   list Q86. Name few classes that implement Queue interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_1.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections.queue Q87. Name few classes that implement Collection interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   collection interface Q88. Name few Hash collections classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-hash-collections-classes-and.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   hash collections Q89. Name few Queue classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-collections-queue-classes-and.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   queue Q90. What are few iterator classes provided by Java ?
Ans. http://www.buggybread.com/2015/01/java-iterator-classes-and-interfaces.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   iterator