Tuesday 12 March 2013

JAVA INTERVIEW QUESTIONS

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.