Showing posts with label JSP. Show all posts
Showing posts with label JSP. Show all posts

Thursday, August 11, 2016

Java interview questions for 3 years of experience candidate....

Here i am listing all the interview question, who is having 3 years of experience.

Hibernate Related Question:
  • What is the difference between session.get() and session.load() method in hibernate ?
  • What is the difference between session.update() and session.merge() ?
  • What is first level and second level cache in hibernate ?
  • Can we access a data from data base without using primary key ?
  • How to use composite key in hibernate, how to retrieve and store the data using composite key ?
  • How to communicate with multiple data bases like mysql and oracle from hibernate ?
  • What is the schema in hibernate, How to use it and when to use it ?
  • What is the relationship in hibernate , what are the types and how to declare it ?
  • How to make a pojo as an entity in Hibernate ?
  • What is the difference between eager and lazy loading in hibernate and how to configure it ?
  • What is dirty checking in hibernate ?
  • What optimistic and pessimistic locking in hibernate ?
  • What is the purpose of @Version ? 
  • Dirty checking in hibernate ?
  • What is scalar and how to use it ?
JDBC Related Questions:
  1. How to use jdbc transaction, when it will start the transaction in jdbc code?
  2. What is connection pooling, how to configure and how it will work ?
  3. What are the steps to write a jdbc program ?
  4. What is the difference between statement, prepared statement and callable statement in jdbc ?
  5. How to store image in data base using jdbc, what parameter we have to use to store image ?
  6. How to call a stored procedure in jdbc ?
Spring IOC Related Questions:

  1. What are the IOC container in spring ?
  2. How many types of handler mapping and how to configure,what is the  difference among them ?
  3. Different types of controllers 
  4. Different types of view resolver ?
  5. How many types of injection are there in spring IOC ?Which one is better ?
  6. What is Inversion Of Control ?
  7. What is dependence injection ?
  8. What is the scope and how many types of scope are there in spring IOC ?
  9. What is the difference between singleton and prototype ?
  10. what is the difference between application context and bean factory container in spring IOC ?
  11. What are the interceptor in spring IOC ?
  12. How the IOC container will read the spring configuration file, if we have a customized spring configuration name ?
  13. what is the context listener in web.xml file, how to configure the context listener in web.xml file to read the spring configuration file ?


Spring MVC Related Questions:
  1. What are the annotations, which you used in your project ?
  2. What is @Qualifier annotation in spring mvc ?
  3. What is @Autowired annotation in spring mvc ?
  4. How to enable annotation in  spring mvc ?
  5. How to read the annotation from the controller in spring mvc, what we have to declare in the spring configuration file ?
  6. What is the Spring MVC flow, Explain with diagram ?
  7. what is the difference between @RestController and @Controller in spring MVC ?
  8. What is @Required annotation and at what situation we have to use it in spring MVC ?
  9. What scope do we have to use to get the new object for every request in spring ?
  10. What is Multipart file and what is the use of it ?
  11. what is the Inversion of Control in spring ?
  12. How to schedule a bean in spring ?
  13. How to restrict the service provide to send only the xml format data and how to send only the XML formatted data from spring MVC controller ?
  14. What is @InitBinder in spring mvc ?
  15. What is @Pattern annotation in spring mvc ?
  16. What are the customer property editor in spring mvc ?
J2SE Related Questions:
  1. What is the purpose of  extends and super key words in Generics, When to use it ?
  2. What is the purpose of generics in Java ?
  3. What is OOP'S concepts in Java ?
  4. What is the difference between exception and error, How to handle them using java ?
  5. What is the difference between ArrayList and Linked List ?
  6. What is the difference between HashMap and HashSet ?
  7. What is the difference between Comparable and Comparator ?
  8. What is the difference among String , StringBuilder and StringBuffer ?
  9. What is the life cycle of Thread in java ?
  10. What is the difference between Yield and Sleep method in Thread class ?
  11. What is the difference between Join, Yield and Sleep method in Thread class in java ?
  12. How to sort the elements in ArrayList ?
  13. What is the difference between Abstract class and Interface, Where to use it ?
  14. What are the features on java 1.5,1.6,1.7 and 1.8 ?
  15. What is the HashSet and TreeSet in collections ?
  16. What is String and how to replace a new string value from the  existing string value ?
  17. How to find the file is empty or not using File IO package ?
  18. How to find the file is exist or not using the file IO package ?
  19. How to read the specified line from a file using File IO package ?
  20. What is the difference between File Input Stream and Buffered Input Stream in File IO package ?
  21. What if File Reader and File Writer ?
  22. Which way is the better way to implement multi threading either implementing Runnable  interface or extending Thread class ? 
  23. what is Aggregation and composition in java ?
  24. what is is-a ,has-a relationship in java ? 
Restful Web Service related questions:

  1. How to consume a json object in restful web services ?
  2. How to access restful web services from client application ?
  3. What is query param in restful web services of jersey ?
  4. What is the Path Param in restful web services ?
  5. What is the different between POST and PUT annotation in restful web services ?
SOAP Web Services related questions:


  1. what is schema in SOAP web services ?
  2. What is the top down and bottom up approach ?
  3. Which approach did you followed in your project for SOAP ?
  4. How to access the SOAP web services from client application ?




MySQL related questions :


  1. How to copy the data from one table to other table ?
  2. How to find only the unique records from the table where there are duplicate records is exists?(Distinct)
  3. How to fetch the last 10 records from a table ?
  4. what is sub queries and co related sub queries ?















Saturday, July 9, 2016

What is request dispatcher and how many ways we can create an dispatcher object

Request Dispatcher :


Request Dispatcher is an interface which is having two methods forward(request, response) and include(request,response).

Defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server. The servlet container creates the RequestDispatcher object, which is used as a wrapper around a server resource located at a particular path or given by a particular name.

This interface is intended to wrap servlets, but a servlet container can create RequestDispatcher objects to wrap any type of resource.

Simple explanation of request dispatcher is to forward control(request) to the next resource (like jsp,servlet or html) which has to do the processing of the request  and it will return the result to the end user or it can return the processed request to the calling function to fulfill the remaining processing of the request then the calling function will return the result to the end user.

We can create Request dispatcher in two ways

ServletContext context = getServletContext();
                 RequestDispatcher dispatcher = context.getRequestDispatcher("/processing.jsp");
                 dispatcher.forward(request,response);
RequestDispatcher requestDispatcher; 
requestDispatcher = request.getRequestDispatcher("/thankYou.jsp");   
requestDispatcher.forward(request, response); 
requestDispatcher.include(request,response);

Monday, June 20, 2016

Translating JSP scriptlet code to servlet service life cycle method

Scriptlets are nothing but java code enclosed within <% and %> tags. JSP container moves the statements enclosed in it to _jspService()method while generating servlet from JSP. The reason of copying this code to service method is: For each client’s request the _jspService() method gets invoked, hence the code inside it executes for every request made by client.
Syntax of Scriptlet:
[code language=”java”]<% Executable java code%>[/code]

JSP to Servlet transition for Scriptlet –

As I stated in my previous tutorials that JSP doesn’t get executed directly, it first gets converted into a Servlet and then Servlet execution happens as normal. Also, I explained in first para that while translation from JSP to servlet, the java code is copied from scriptlet to _jspService() method. Lets see how that happens.
Sample JSP code:
[code language=”html”]

Sample JSP


<% myMethod();%>
[/code]
Note: Semicolon at the end of scriptlet.
Corresponding translated Servlet code for above JSP code:
[code language=”java”]
public void _jspService(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
HttpSession session = request.getSession();
JspWriter out = response.getWriter();
out.println("

Sample JSP

");
myMethod();
}[/code]