Java Interview Questions and Answers Set 8

71.Can we call the run() method instead of start()?

yes, but it will not work as a thread rather it will work as a normal object so there will not be context-switching between the threads.

72.What is Session Facade?

Session Facade is a design pattern to access enterprise bean through local interface. It abstracts the business object interactions and provides a service layer. It makes the performance fast over network.

73.How can I implement a thread-safe JSP page? What are the advantages and Disadvantages of using it?

You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This is done by adding the directive <%@ page isThreadSafe=”false” %> within your JSP page.

74.How is JSP used in the MVC model?

JSP is usually used for presentation in the MVC pattern (Model View Controller ) i.e. it plays the role of the view. The controller deals with calling the model and the business classes which in turn get the data, this data is then presented to the JSP for rendering on to the client.

75. What are context initialization parameters?

Context initialization parameters are specified by the <context-param> in the web.xml file, these are initialization parameter for the whole application and not specific to any servlet or JSP.

76.What does modelDriven interceptor?

The modelDriven interceptor makes other model as the default object of ValueStack. By default, action is the default object of ValueStack.

77.What is the role of IOC container in spring?

IOC container is responsible to:

  • create the instance
  • configure the instance, and
  • assemble the dependencies

78.What are the transaction management supports provided by spring?

Spring framework provides two type of transaction management supports:

  • Programmatic Transaction Management: should be used for few transaction operations.
  • Declarative Transaction Management: should be used for many transaction operations.

79.What is the advantage of NamedParameterJdbcTemplate?

NamedParameterJdbcTemplate class is used to pass value to the named parameter. A named parameter is better than ? (question mark of PreparedStatement).

80.Why we override equals() method?

The equals method is used to check whether two objects are same or not. It needs to be overridden if we want to check the objects based on property.

For example, Employee is a class that has 3 data members: id, name and salary. But, we want to check the equality of employee object on the basis of salary. Then, we need to override the equals() method.