Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Core java - Interview Questions and Answers for 'Credit agricole' - 3 question(s) found - Order By Newest | ||||
Very frequently asked. Favorite question in Walk in Drive of many Indian service companies. | ||||
| ||||
Ans. Underlying data structure for ArrayList is Array whereas LinkedList is the linked list and hence have following differences - 1. ArrayList needs continuous memory locations and hence need to be moved to a bigger space if new elements are to be added to a filled array which is not required for LinkedList. 2. Removal and Insertion at specific place in ArrayList requires moving all elements and hence leads to O(n) insertions and removal whereas its constant O(1) for LinkedList. 3. Random access using index in ArrayList is faster than LinkedList which requires traversing the complete list through references. 4. Though Linear Search takes Similar Time for both, Binary Search using LinkedList requires creating new Model called Binary Search Tree which is slower but offers constant time insertion and deletion. 5. For a set of integers you want to sort using quicksort, it's probably faster to use an array; for a set of large structures you want to sort using selection sort, a linked list will be faster. | ||||
Sample Code for ArrayList Sample Code for LinkedList | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  collections   java   data structures   arraylist   linkedlist   arraylist vs linkedlist Asked in 61 Companies Basic   frequent | ||||
Try 1 Question(s) Test | ||||
Related Questions | ||||
If you are given a choice to use either ArrayList and LinkedList, Which one would you use and Why ? | ||||
Will this code give error if i try to add two heterogeneous elements in the arraylist. ? and Why ? | ||||
In a Linked list with sorted numbers, insert a new numbers while maintaining the sort order. | ||||
Collections.sort can only be performed on .. a. Set b. List c. Map d. Any Collection implementation | ||||
Is this a valid initialization ? Explain. Collection<Collection> collection = new LinkedList<LinkedList>(); | ||||
What is the difference between List, Set and Map ? or What are the different Java Collections Interfaces ? | ||||
Difference between Vector and ArrayList ? | ||||
Overridden methods must have the same ... | ||||
Which of the following doesn't extend Collection interface ? | ||||
| ||||
Ans. The memory pool containing all the reflective data of the java virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas. The Permanent generation contains metadata required by the JVM to describe the classes and methods used in the application. The permanent generation is populated by the JVM at runtime based on classes in use by the application. In addition, Java SE library classes and methods may be stored here. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   jvm   memory management   permgen   permanent generation   advanced   architecture Asked in 9 Companies expert | ||||
Related Questions | ||||
What are different ways to create String Object? Explain. | ||||
Does garbage collection guarantee that a program will not run out of memory? | ||||
Describe, in general, how java's garbage collector works ? | ||||
Describe what happens when an object is created in Java ? | ||||
What are various types of Class loaders used by JVM ? | ||||
Why two types of memory - stack and heap are required by Java ? | ||||
Should we override finalize method ? | ||||
What are strong, soft, weak and phantom references in Java ? | ||||
Which memory areas does instance and static variables use ? | ||||
Can we call the garbage collector explicitly ? | ||||
| ||||
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 | ||||
Related Questions | ||||