Saturday, August 22, 2009

Java Interview Questions

I was recently interviewed for a project, here is a log of questions.
Threads
1. Threads have priorities 1 to 9, which is the highest and which one is the lowest.
2. I have a class which has two methods add and subtract, both the methods are synchronized, a thread went into add method and the same time another thread tries to get into subtract method, which it wait for first thread to complete add or will it go into subtract thread.
3. What are critical sections.
4. Which one is a better practice to have functions synchronized or to have synchronize block.
5. What are the different states that a thread goes through.
Servlets & JSP
1. what are servlet config and servlet context, how are they different than each other.
2. What are the different ways of maintaining session.
3. How do we maintain session in a clustered environment.
4. Describe life cycle of a JSP.
Other
1. What is heap memory.
2. What are Xms and Xms.
3. How do we maintain transactions in Hibernate.
4. What are Spring IOC and Dependency Injection, how are they different than each other.
5. What are the benifits of using Spring IOC.
6. I have a class which has two variables name and roll no, this class is serialized, now I have two different conditions in one I do not want rollno to ge serialized, how can serialized interface help me in this.

No comments: