In this article, I am going to share some of the good Java Interview questions based upon ArrayList class. I have hardly seen a Java interview without any question from ArrayList, and why not its one of the most popular collection class and every Java developer use it on their day to day work. Another reason of asking question related to ArrayList is that you can ask wide variety of question to really check breadth and depth of candidate's knowledge. To give you some idea about ArrayList, its a collection class which implements List interface. Its an alternative of array data structure whose size you cannot change once created. ArrayList is a dynamic array, which can grow and resize itself. By implementing List interface it also got some properties e.g. ordering, ArrayList keeps element in the order they are inserted and it also provides constant time search operation if you know index of element e.g. get(index) is O(1) operation. This makes ArrayList ideal choice when you are looking to retrieve values based upon index. On contrary to search, adding and removing in ArrayList is little costly because it can trigger re-sizing, which involves creating a new array and copying all elements from old array to new array. I am sure you know the basics but you will learn more by going through some of these frequently asked Java ArrayList questions. You can also take help of the
Java Programming Interviews Exposed by Markham, one of the best book to prepare for Java interviews.