Monday, February 4, 2013

Important Java Interview Questions.

I will try to write a series of some of the really good and interesting questions which every Java programmer should know from interview's prospective as well as from coding's prospective.

Here is a list. I will try to write answers as I get free time.

1. What are clustered and non-clustered index.
2. Difference between trigger and stored procedure.
3. what is singleton, synchronize singleton. write code for singleton, walk through code and show how multiple instance will be created in case of multiple threading. synchronize singleton, double check synchronized singleton. lazy loading, eager loading in singleton. volatile keyword and use it in singleton. singleton with public static.
4. difference between hashmap and hashset. which one is derived from which.
5. what is jdbc template--spring.
6. what is IOC.
7. what is dependency injection.
8. what is callable interface.explain it and how and where to use it.
9.write code for producer-consumer scenerio. producer have a pool of 10 threads, consumers haev a pool of 10 threads, producer are constantly producing and consumers are consuming. if consumer is not consuming fast enough, producer should wait for producing till there is a slot available.
10. what is session, session factory--hibernate.
11. builder design patters, factory design patter, difference between them.
12. explain how hashmap works in java.
13. explain memory model and garbage collection in java.(how to do memory optimization in java for out of memory errors)(full memory model, why memory model is devided in to different parts, like young generation, old generation, permgen, why not have a single big heap.)
14. if there is a building with 100 floors , find the higest floor to drop eggs safely (binary tree. start with 100th floor,  then 50th floor.)
15. wrote code to find biggest bcd for 2 number.
16. what are OPPS concept, what is Object Oriented.
17. give examples of how multi-threading is being used in your application.(with sample code)
18. notify, notifyall,
19. Explain one to one and many to one mappings in Hibernate.
20. Difference between inner join, outer join.
21. If there are two transactions and if any of them fails, We do not want to save their data. How will you handle this.
22. Initiate a transaction in spring once and then commit two transactions or mulitple transactions without initiating another transaction session.