![]() ![]() On the other hand if you are storing a custom object in Sorted Collection e.g. What do you need to do to use a custom object as key in Collection classes like Map or Set?Īnswer is : If you are using any custom object in Map as key, you need to override equals() and hashCode() method, and make sure they follow there contract. ![]() One Java Collection Interview Question, which I have faced more often in JP Morgan, Cognizant and HSBC recently : Difference between ArrayList and Vector has been asked to my friend on his Java interview with Wipro and TCS last month. I think Collection interview questions listed here are very much appear in Capegemini or Tech Mahindra interview. Now days no buddy asked about List, Set or Map they ask questions on Concurrent Collections, Synchronized Collections etc.Ĭan you please share some Java collection intervie questions asked on Capegemini, Tech Mahindra, TCS, Patni, Mahindra Satyam, HSBC, WIPRO and Cognizant, I am making list, please help Hello Sir, Can you please share interview question from new Collection classes introduced in Java 5 and Java 6 like BlockingQue, DeQueue, NavigationalMap etc. By the way can you please share pdf version of your java collection interview for download ? If anyone wants to answer this question, they must required a very good understanding of Java Collection framework which is whole purpose of these interview questions.Ĭore java interview questions on collections are second most asked java questions after thread and String. These interview questions seems to be too common and appear in almost many interviews and that's the reason I never asked so called frequently asked or popular interview question, instead I ask something which is not so common like:ġ) What is CopyOnWriteArrayList, how it is different than ArrayList and Vector?Ģ) Why ListIterator has add() method but Iterator doesn't or Why add() method is declared in ListIterator and not on Iterator.ģ) Can we replace Hashtable with ConcurrentHashMap?ĥ) How does LinkedList is implemented in Java, is it a Singly LinkedList or Doubly LinkedList?Ħ) Which one you will prefer between Array and ArrayList for Storing object and why? (Generics, dynamic growing )ħ) What is BlockingQueue, how it is different than other collection classes( flow control)Ĩ) How do you iterator over Synchronized HashMap, do you need to lock iteration and why ?ĩ) When does ConcurrentModificationException occur on iteration?ġ1) Difference between Set, List and Map Collection classes?ġ2) How does HashSet is implemented in Java, How does it uses Hashing ? BTW, if you are preparing for a Java interview then you can also take help from these Java interview courses and books, both are resources to do well in Java interviews. These Java Collection framework interview questions have been collected from various friends and colleagues and Answers to these interview questions can also be found by Google. In this article, we will see a mix of some beginners and advanced Java Collection interviews and their answers which have been asked in various Core Java interviews. I think the main reason for this delay could be spending a lot of time researching and preparing the mega list of core Java questions from the last 5 years. Though I have shared several questions individually in between. ConcurrentHashMap when I first wrote 10 multi-threading Interview questions but somehow this article got delayed. I thought about writing interview questions on the Java collection framework and important classes like ArrayList, HashMap, Hashtable, and newly added concurrent collections e.g. Together Collection and multithreading make any Java interview tough to crack and having a good understanding of Collection and threads will help you to excel in Java interviews. A thread’s id is assigned the first time it invokes ThreadId.get() and remains unchanged on subsequent calls.Interview questions from the Collection package or framework are most common in any Core Java Interview yet a tricky one. The example below, from the ThreadLocal Javadoc, generates unique identifiers local to each thread. ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread (e.g., a user ID or transaction ID). ![]() Each thread that accesses the get() or set() method of a ThreadLocal instance is accessing its own, independently initialized copy of the variable. A single ThreadLocal instance can store different values for each thread independently. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |