Java Software Engineer Question:
Download Questions PDF

Can you give real world examples of when to use an ArrayList and when to use LinkedList?

Answer:

ArrayList is preferred when there are more get(int), or when search operations need to be performed as every search operation runtime is O(1).

If an application requires more insert(int) and delete(int) operations, then LinkedList is preferred, as LinkedList does not need to maintain back and forth to preserve continued indices as arraylist does. Overall this question tests the proper usage of collections.

Download Java Software Engineer Interview Questions And Answers PDF

Previous QuestionNext Question
int a = 1L;
won’t compile and int b = 0;
b += 1L;
compiles fine. Explain me why?
Tell us why would it be more secure to store sensitive data (such as a password, social security number, etc.) in a character array rather than in a String?