1. What is the strategy to handle ConcurrentModificationException in your Java program.
2. How hashmap identify index for element to insert?
3. What is default size of bucket in hashmap? and formula of rehash size?
4. Comparable VS Comparator
5. Write Comparator for employee class having id and name?
6. ArrayList VS LinkedList
7. Can we add null to TreeSet? if No why?
8.
ArrayList<String> s = new ArrayList<String>();
ArrayList<Integer> s1 = new ArrayList<Integer>();
System.out.println(s1.equals(s));
why ans is always equals
why ans is always equals
9. Implement own linked list.
10. Implement own linked list.
11. What is the difference between HashMap and Synchronized map.
12. how does blocking queue works?
13. Which collection should use where you keep elements like list. With out using AL or LL ?
14. How to write your own doubly link list? How do you handle boundary conditions?
15. Why java have “for loop”, foreach loop, iterator and ListIterator for traversing ArrayList,
List out difference between them and give valid reason what you prefer.
Ans
for loop - Good to traversing Arraylist only, If you are not sure underlying data structure do not use for loop for traversing as for linked list N^2 time complexity
For Each Loop - can call methods of element
Iterator :
// 1 - can call methods of element // 2 - can use iter.remove() to remove the current element from the list
ListIterator :
// 1 - can call methods of element // 2 - can use iter.remove() to remove the current element from the list // 3 - can use iter.add(...) to insert a new element into the list // between element and iter->next() // 4 - can use iter.set(...) to replace the current element
16. What will be behavior of a Java Program where infinite recursion takes place with limited Stack memory ? Does the program complete or Stackoverflow exception is thrown ?
17. How to handle multiple request using concurrency utilities?
No comments:
Post a Comment