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. |
|
| |||||||||||
Interview Questions and Answers - Order By Rating | |||||||||||
Advanced level question frequently asked in US based companies. Recently asked in EMC and Intuit. | |||||||||||
| |||||||||||
Ans. Simplest implementation we can have is a List wherein we can place ordered words and hence can perform Binary Search. Other implementation with better search performance is to use HashMap with key as first character of the word and value as a LinkedList. Further level up, we can have linked Hashmaps like , hashmap { a ( key ) -> hashmap (key-aa , value (hashmap(key-aaa,value) b ( key ) -> hashmap (key-ba , value (hashmap(key-baa,value) .................................................................................... z( key ) -> hashmap (key-za , value (hashmap(key-zaa,value) } upto n levels ( where n is the average size of the word in dictionary. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   collections   hashmap   binary search   search algorithm   advanced   architecture   data structure Asked in 6 Companies   frequent | |||||||||||
Try 1 Question(s) Test | |||||||||||
Frequently asked to experienced developers. Recently asked in many US interviews. | |||||||||||
| |||||||||||
Ans. When multiple external resources are trying to access the DB locks and runs into cyclic wait, it may makes the DB unresponsive. Deadlock can be avoided using variety of measures, Few listed below - Can make a queue wherein we can verify and order the request to DB. Less use of cursors as they lock the tables for long time. Keeping the transaction smaller. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   database   architecture Asked in 7 Companies expert   frequent | |||||||||||
Very frequently asked if being interviewed for hibernate. Frequently asked in Tata Consultancy (TCS) and Overstock.com | |||||||||||
| |||||||||||
Ans. If id doesnt exist in the DB load throws an exception whereas get returns null in that case.get makes the call to DB immediately whereas load makes the call to proxy. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  hibernate Asked in 16 Companies basic   frequent | |||||||||||
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 | |||||||||||
| |||||||||||
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 | |||||||||||
| |||||||||||
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 | |||||||||||
| |||||||||||
Ans. Jar is Java Archieve i.e compressed Class or Class / Java files. War comprises of compressed Servlet class files,JSP FIles,supporting files, GIF and HTML files. Ear comprise of compressed Java and web module files ( was files ). | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   j2ee   jar   web development   war   ear   build management   release management Asked in 12 Companies basic   frequent | |||||||||||
| |||||||||||
Ans. Server Configuration files | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  ear   deployment   servers   java | |||||||||||
Almost sure to be asked in every company using any Dependency Injection framework ( Spring, Guice etc ) | |||||||||||
| |||||||||||
Ans. It is a Design Pattern that facilitates loose coupling by sending the dependency information ( object references of dependent object ) while building the state of the object. Objects are designed in a manner where they receive instances of the objects from other pieces of code, instead of constructing them internally and hence provide better flexibility. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  design patterns   ioc ( Inversion of Control )  dependency injection Asked in 83 Companies intermediate   frequent | |||||||||||
Frequently asked in face to face interviews. | |||||||||||
| |||||||||||
Ans. int count = 15; int[] fibonacci = new int[count]; fibonacci[0] = 0; fibonacci[1] = 1; for(int x=2; x < count; x++){ fibonacci[x] = fibonacci[x-1] + fibonacci[x-2]; } for(int x=0; x< count; x++){ System.out.print(fibonacci[x] + " "); } | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  ebay   fibonacci series Asked in 66 Companies basic   frequent | |||||||||||
| |||||||||||
Ans. Destructor is used to de-allocate memory allocated by objects. There are no destructors in Java. Alternatively, Java provides Automatic garbage collection i.e automatically releasing the un-referenced memory. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  destructor  garbage collection Asked in 11 Companies Basic   frequent | |||||||||||
Try 1 Question(s) Test | |||||||||||
| |||||||||||