1) project related questions
2) what is reenterenet lock
3) diff with syn v/s reenterenent
4) diff between ? and T extend ?
5) diff between lock v/s synchronized
6) diff bet concurrentHashmap ,synchronizedHashmap-- how it works
7) treeset v/s hashset
8) hashing algorithm
9) how to do db table partitioning
10) how can increase performance of db tables...getting records
11) how to merge two sorted int array
12) how to sort int array of n number --- various ways
13) recusive method of factorial/fibonacci
14) deadlock v/s race v/s starvation v/s live lock
15) how to prevent from above condition
16) compile time v/s runtime polymorphism
17) how to prevent child class from serialozation if parent is serlizable
18) JDBC
19) char array given ,how to reverse this array without using api or creating new object
20) concurrent hashmap and its functionality.
21) Reenterent lock and functionality.
22) Singleton pattern implementation.
23) String class implementation.
24) Executor pattern.
25) Final char[] arr = {'a','b','c'}; then char[0] = 'd'; possible or not?
26) Immutable objects.
27) Servlet destroy() call in init() ,wht will happen?
28) struts v/s spring?
29) spring DI
30) Spring MVC flow
31) singleton code
32) hibernate association,configuration
33) immutable class
34) dispatch action
35) empname,mgrname from same emp table which have col empid,name,mgrid
36) used design patterns
37) service locator
38) jndi how confirgured for hibernate
39) webservice-- wsdl-
40) junit-mocking of any dao
41) code review tool
42) continous integration ?
43) findbug,pmd,checkstyle- sonar.
44) how hasmap works internally.
45) what is synchronization?
45) how will you implement singleton class?
46) difference between factory and abstractFactory?
47) difference between arraylist and linked list?
48) difference between arraylist and hashmap?
49) what are locks?
50) if you have two interfaces having same method in these, now you are implementing these two interfaces in your class. Will there be any issue with it?
51) what is hasing?
52) difference between hashmap and hashtable?
53) you have a very huge arraylist, which is having duplicate values. how will you get a collection of unique entities from this arraylist?
54) difference between Exception and Error? can we catch Exceptions and Errors in our java code?
55) how will you do the performance improvement in you project?
56) how customer layer communicates with the service layer.?
57) basic functioning of JMS.
58) what all design patterns have you implemented in your project?
59) what are joins?
60) you have an employee table, having ID, name, managerName, DeptId. Now you need to show the employee name and his manager from it.
61) you have employee table, and department table. employee having id, dept, salary and name. Dept is having dept id and name.
now you need to show all the department where the average salary of the department > 10000.
62) You have a synchronized method in a Class ABC, say public synchronized void show(){}, now you have created an object of this ABC a1
now, two threads t1 and t2 wants to access the two methods on this object "a1". is it possible to execute these two synchronized methods with the same object?
63) you have a class Parent and a class Child extends Parent. These two classes have a method public void show(){}.
now you are doing Parent p = new Child();
p.show();
which method is gonna call through this statement?
what if both these two methods are static methods?
64) you have millions of number, and you need to find the highest number from this. how will you do that, it should be performance efficient.
65) what is the difference between Lock and synchronized.
66) what if you dont override hashcode method of your class and using this object as a key to store the values in a hashmap?
67)
**************************************************************************
ASked to someone
1.Describe current project with architecture
2.what is the difference between extend thread class and implementing unable interface.
3.what is the difference between ear, war, and jar.
4.what is realization, why it is used. what is transient variable.
5.can we put duplicate key in map and can we put multiple values in map?
6.Difference between jip and served. explain jip life cycle.
7.Difference between mvc1 and mvc2
8.explain struts1.1 flow.
**************************************************************************
1) Difference between LIST and SET, HashMap and HashSet, Vector and ArryList, ArrayList and LinkedList, which can be used in which scenario.
2) How HashMap works.
3) equals and hashcode
4) Colletion sorting - comparable and comparator.-what can be the defination of overriten methods. how it works.
5) new String("abc") - how many objects created. and what happens in memory.
6) String str[] = new String[3]{"a","b","c"} same if we have array of integer- what happens in memory
7) Immutable Object - how can we make class as immutable.
8) Serilization - what is serialVersionNo. if used in class and Serilizable is not implemented.
9) drawback of Serilizable interface
10) Externlizable and its two methods - what can we do with this two methods.
11) how can we share information between two threds.
12) Statics Synchronized method, Synchronized method, normal method.
i) if two threads accessing these methods - what will happen in each case.
ii) if we have two objects containing all above methods and two threads accessing two objects differently, what will happen.
13) difference between sleep and wait.
14) Tell me about String class.- Is String class is thread-safe.
15) enumeration and iterator and list-iterator. differences
16) fail-safe and fail-false.
17) HashMap, SynchronizedHashMap, concurrentHashMap
18) how can we find duplicates in arraylist - with Collecyions.frequency
19) how Jprofiler configured with application.
20) what about maven. in descriptive.
2) what is reenterenet lock
3) diff with syn v/s reenterenent
4) diff between ? and T extend ?
5) diff between lock v/s synchronized
6) diff bet concurrentHashmap ,synchronizedHashmap-- how it works
7) treeset v/s hashset
8) hashing algorithm
9) how to do db table partitioning
10) how can increase performance of db tables...getting records
11) how to merge two sorted int array
12) how to sort int array of n number --- various ways
13) recusive method of factorial/fibonacci
14) deadlock v/s race v/s starvation v/s live lock
15) how to prevent from above condition
16) compile time v/s runtime polymorphism
17) how to prevent child class from serialozation if parent is serlizable
18) JDBC
19) char array given ,how to reverse this array without using api or creating new object
20) concurrent hashmap and its functionality.
21) Reenterent lock and functionality.
22) Singleton pattern implementation.
23) String class implementation.
24) Executor pattern.
25) Final char[] arr = {'a','b','c'}; then char[0] = 'd'; possible or not?
26) Immutable objects.
27) Servlet destroy() call in init() ,wht will happen?
28) struts v/s spring?
29) spring DI
30) Spring MVC flow
31) singleton code
32) hibernate association,configuration
33) immutable class
34) dispatch action
35) empname,mgrname from same emp table which have col empid,name,mgrid
36) used design patterns
37) service locator
38) jndi how confirgured for hibernate
39) webservice-- wsdl-
40) junit-mocking of any dao
41) code review tool
42) continous integration ?
43) findbug,pmd,checkstyle- sonar.
44) how hasmap works internally.
45) what is synchronization?
45) how will you implement singleton class?
46) difference between factory and abstractFactory?
47) difference between arraylist and linked list?
48) difference between arraylist and hashmap?
49) what are locks?
50) if you have two interfaces having same method in these, now you are implementing these two interfaces in your class. Will there be any issue with it?
51) what is hasing?
52) difference between hashmap and hashtable?
53) you have a very huge arraylist, which is having duplicate values. how will you get a collection of unique entities from this arraylist?
54) difference between Exception and Error? can we catch Exceptions and Errors in our java code?
55) how will you do the performance improvement in you project?
56) how customer layer communicates with the service layer.?
57) basic functioning of JMS.
58) what all design patterns have you implemented in your project?
59) what are joins?
60) you have an employee table, having ID, name, managerName, DeptId. Now you need to show the employee name and his manager from it.
61) you have employee table, and department table. employee having id, dept, salary and name. Dept is having dept id and name.
now you need to show all the department where the average salary of the department > 10000.
62) You have a synchronized method in a Class ABC, say public synchronized void show(){}, now you have created an object of this ABC a1
now, two threads t1 and t2 wants to access the two methods on this object "a1". is it possible to execute these two synchronized methods with the same object?
63) you have a class Parent and a class Child extends Parent. These two classes have a method public void show(){}.
now you are doing Parent p = new Child();
p.show();
which method is gonna call through this statement?
what if both these two methods are static methods?
64) you have millions of number, and you need to find the highest number from this. how will you do that, it should be performance efficient.
65) what is the difference between Lock and synchronized.
66) what if you dont override hashcode method of your class and using this object as a key to store the values in a hashmap?
67)
**************************************************************************
ASked to someone
1.Describe current project with architecture
2.what is the difference between extend thread class and implementing unable interface.
3.what is the difference between ear, war, and jar.
4.what is realization, why it is used. what is transient variable.
5.can we put duplicate key in map and can we put multiple values in map?
6.Difference between jip and served. explain jip life cycle.
7.Difference between mvc1 and mvc2
8.explain struts1.1 flow.
**************************************************************************
1) Difference between LIST and SET, HashMap and HashSet, Vector and ArryList, ArrayList and LinkedList, which can be used in which scenario.
2) How HashMap works.
3) equals and hashcode
4) Colletion sorting - comparable and comparator.-what can be the defination of overriten methods. how it works.
5) new String("abc") - how many objects created. and what happens in memory.
6) String str[] = new String[3]{"a","b","c"} same if we have array of integer- what happens in memory
7) Immutable Object - how can we make class as immutable.
8) Serilization - what is serialVersionNo. if used in class and Serilizable is not implemented.
9) drawback of Serilizable interface
10) Externlizable and its two methods - what can we do with this two methods.
11) how can we share information between two threds.
12) Statics Synchronized method, Synchronized method, normal method.
i) if two threads accessing these methods - what will happen in each case.
ii) if we have two objects containing all above methods and two threads accessing two objects differently, what will happen.
13) difference between sleep and wait.
14) Tell me about String class.- Is String class is thread-safe.
15) enumeration and iterator and list-iterator. differences
16) fail-safe and fail-false.
17) HashMap, SynchronizedHashMap, concurrentHashMap
18) how can we find duplicates in arraylist - with Collecyions.frequency
19) how Jprofiler configured with application.
20) what about maven. in descriptive.
Difference between LIST and SET, HashMap and HashSet, Vector and ArryList, ArrayList and LinkedList, which can be used in which scenario?
ReplyDeleteList is an ordered collection where one is having the control of the position where a new element in a list is inserted. Accessing an element is directly through the index. List can contain duplicate values.
On the other hand a set is an unordered collection and user doesnt have control over the position of an element where it get stored. It doesnt allow duplicate values to be inserted and allow atmost one NULL. If you try to put duplicate value in Set, it will overright the older value. Though Set is unordered collection and doesnt maintain the order in which the elements are inserted in Set, SortedSet is one collection which can maintain the order of insertion in the collection(using Comparable and Comparator methods of object in Set).
List in java is also implemented as Arraylist, LinkedList and Vector, while Set is implemented as TreeSet, HashSet and LinkedHashSet.
WHEN TO USE LIST AND SET IN JAVA:
If you require to maintain the order of elements and can allow duplicate values, then you can go with LIST while if your requirement says order doesnt matter but the uniqness does, then Set is the way to go..
One can also consider the coplexity of insertion in case of list and set.
DeleteSince, a set assures uniqness, it does the validation before inserting an element, it makes set slower than list.
HOW HASHMAP WORKS?
ReplyDeleteHashmap works on the principle of hashing. We have put(key,value) and get(key) methods in HashMap to insert and to retrieve elements.
When we pass key and value pair in put method, hashmap implementation calls hashcode method on key object and applies returned hashcode into its own hashing function to find out the bucket location in bucket which helps in understanding the retrieving logic.
Problem arises when 2 different objects produces same hashcode.
Hashmap uses key ojbect's hashcode to find out the bucket locaton and retrieve value object. Now in this case, since we have two keys having same hashcode, you will endup getting two value object from a single key, right?
Actually, hashmap stores both key and value in LinkedList node or as a Map.Entry
So after finding the bucket location, we will call key.equals() method to identify the correct node in linkedlist and return associated value for that key object from the hashmap.
*************************************************************
ReplyDelete7) Immutable Object - how can we make class as immutable.
Following points will help you out making a class immutable:
1.Don't provide "setter" methods — methods that modify fields or objects referred to by fields.
2. Make all fields private and final.
3. declare the class as final, so that no one can subclass it.
4. If instance fields having reference to mutable objects, don't allow those objects to be changed.
◦Don't provide methods that modify the mutable objects.
8) Serilization - what is serialVersionNo. if used in class and Serilizable is not implemented.
ReplyDeleteSee my blog on serialization
http://piyvyas.blogspot.fi/search/label/JAVA%20SERIALIZATION
new String("abc") - how many objects created. and what happens in memory.
ReplyDeleteWhen you say String S1= new String(“ABC”);
It creates 1 object in memory and reference to which is return to S1.
A common assumption is that, it will create two object, , 1 is in String constant pool and the other in String nonConstant Pool, which is not true.
from the above expression, if you want jvm to create an object in string pool too,you need to make an explicit call to string's intern() method.
intern() method will create "ABC" object in the string pool.