Java J2EE Interview Questions

Recently I have attend the interview in one of the reputed MNC company for JAVA/J2EE technologies.  I tried my level best to recollect all interview questions that I have faced are listed here:

JAVA/J2EE Interview questions

  1. What are the features newly introduced in JAVA SE 5.0
  2. What is the necessity of Generic Programming?
  3. Syntax of Generic Class and Methods declaration
  4. Give collection hierarchy
  5. Which collections are sorted.
  6. Difference between Arraylist and Vector
  7. Difference between Collection and Collections
  8. If I want to sort ArrayList, what we need to do.
  9. Difference between Comparable and Comparator.
  10. What compareTo() method will return and explain each returned data.
  11. Difference between checked and unchecked exception
  12. Hierarchy of Exceptions
  13. Do we need to catch Error? Difference between Error and Exception
  14. List some checked and unchecked exception
  15. Do we need to make sure anything when we write try-catch blocks
  16. Will the statements after catch block run when after an exception was raised in try block.
  17. When finally block executes
  18. What is the use of throws keyword
  19. What are the methods to create thread?  Which is best method?
  20. Does the Thread class implements Runnable interface.
  21. When we implement Runnable interface, which method do we need to implement.
  22. How you will start the thread for execution.
  23. What will happen when you call start () method.  Can I start thread without start () method?
  24. What will happen when we explicitly call run() method to start execution without start() method
  25. Difference between sleep() and wait() methods
  26. When sleep time expired, will the thread enters runnable state or running state.
  27. Difference between notify() and notifyall() methods
  28. Difference between abstract and interface
  29. When we go for abstract and when we go for interface.
  30. How do you implement synchronization?  What are the methods?
  31. What is polymorphism?  How do you implement it?
  32. Difference between overriding and overloading?
  33. Do return type should be same when we implement method overriding
  34. Can I override Static methods?  Are you sure?
  35. Default access specifiers of method declarations in Interface
  36. Default access specifiers of variable declarations in Interface
  37. Can I declare abstract method in non-abstract class

Continues….

34.

Class A {

void display()

{

S.o.p( “class A” );

}

}

Class B extends A

{

void display()

{

S.o.p (“Class B” );

}

}

A obj = new B();

Obj.display();                        //what is the output of this line.

————————————————————————-

Class A {

Static void display()

{

S.o.p( “class A” );

}

}

Class B extends A

{

Static void display()

{

S.o.p (“Class B” );

}

}

A obj = new B();

Obj.display();                        //Are you sure what is the output of this line.  Why??

Class A {

Static int I = 10;

}

Class B extends A

{

Static int I = 30;

}

A obj = new B();

System.out.println(Obj.I);                   //what is the output of this line.

——————————————————-

  1. When garbage collector will run?
  2. Can we call garbage collector? What is the method to call the same?
  3. What is serialization?  How do you implement it?
  4. What happens when serializable object has reference to another object as instance variable?
  5. Difference between private, protected and public access specifiers.
  6. Can I declare static class?
  7. How do you create object for inner class?

J2EE

  1. Lifecycle of Servlet
  2. What is the purpose of init() method.  We can use the servlet constructor for initialization right?  Why do we need init() method still?
  3. Difference between ServletConfig and ServletContext?
  4. Where do you implement ServletConfig and ServletContext parameters?
  5. Do we need to override Service() method while writing Servlet class
  6. Difference between RequestDispatcher and SendRedirect
  7. Can I forward the request if I have already commited the response.  What exception will throw if we already commited a response and forwards the request?
  8. Having Servlet classes, can I use Java Swing instead of JSP in presentation layer?  How do you do that?
  9. How do you create session?
  10. What is the difference between getSession(true), getSession() and  getSession(false)?
  11. How do you declare session timeout in the Deployment Descriptor?

Continues…

  1. What is the difference between GET and POST methods?  What happen If I didn’t declare method attribute in <form> tag?
  2. What are the other HTTP methods?  Purpose of TRACE method?
  3. What is the use of setContentType() method?
  4. How may ways to get reference to ServletContext object?
  5. What is the purpose of ServletContextListener? Give some example when we can use this?
  6. What is the purpose of HttpSessionAttributeListener?  What is the event type of this listener?
  7. Purpose of SingleThreadModel interface?
  8. How does the web container guarantee a servlet gets only one request at a time?
  9. Life cycle of JSP?
  10. List of implicit objects in JSP?
  11. What is the use of application object?  What is the API of out object?
  12. How do import packages in JSP?
  13. How to use <jsp:useBean>….purpose…how to set and get property..?
  14. How do you implement exception handling in JSP?
  15. Difference between include directive and <jsp:include>
  16. What is difference between Statement and Prepared Statement?
  17. What is the use of Callable Statement?
  18. What is inner join?
  19. How do you implement AJAX concept in JavaScript?
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: