Java Interview Questions -31

Java Interview Questions -31

1.How to customize bean destruction process ?

The Spring offers several callback interfaces to modify the behaviour of your bean. By implementing DisposableBean interface Spring Container will call destroy() method .

2.How to implement inheritance in Bean definition ?

Inheritance can be implemented by specifying the ‘parent’ attribute in bean tag and passing id of (parent) the bean that you want to inherit .

3.Explain inner bean in Spring ?

A bean which is defined (embedded) inside the property tag of other bean is called an inner bean. Inner beans can not be used (referred) by other beans except the enclosing one.

4.What is Inversion of Control in spring ?

IOC means inverting the control of creating the object from our own using new operator to Spring container.

5.What are different types of injection in Spring ?

Three types of injection in Spring3 Framework
(1) Setter Injection
(2) Constructor Injection
(3) Getter or Method Injection

6.How to customize bean initialization process ?

The Spring offers several callback interfaces to modify the behaviour of your bean. By implementing InitializingBean interface Spring Container will call afterPropertiesSet() method.

7.benefits of using Spring Framework ?

Spring is relatively light weight container in comparison to other J2EE containers. It does not use much memory and CPU cycles for loading beans, providing services like transaction control , AOP management, JDBC interaction.

8.Describe different modules of Spring Framework ?

Spring comprises of the following modules.
Core container : Basic functionality of Spring is provided by the core container. BeanFactory is the primary component of core container, an implementation of the Factory design pattern.

9.What is BeanFactory ?

BeanFactory ( org.springframework.beans.factory.BeanFactory an interface) acts as Spring IoC container that is responsible for containing, configuring and managing the application beans.

10.What is XmlBeanFactory ?

There are a many implementations of the BeanFactory interface. XmlBeanFactory class is most common implementation of BeanFactory.

11.What is ApplicationContext ?

applicationContext ( org.springframework.context.ApplicationContext ) is an interface which makes Spring a framework. It is derivd from BeanFactory, so has all the functionality of BeanFactory and adds lots more.

12.What is Dependency Injection in Spring ?

In spring objects define their associations (dependencies) and do not worry about how to get those dependencies ; now it is the responsibility of Spring to provide the required dependencies for creating objects.

13.What are the common implementations of the Application Context ?

ClassPathXmlApplicationContext : It loads the context definition from an XML file present in the classpath, treating context definitions as classpath resources.

14.What is Bean wiring ?

The process of linking (associating) beans with each other within a Spring container is called bean wiring. All the Spring managed beans of the application needs to be defined in an xml file.

15.What is auto wiring ?

The Spring container provides the functionality of connecting beans with each other automatically called autowiring . Rather we inject one bean into the other using ref attribute,  Spring can look into the BeanFactory and decide how to inject one bean into the other.

16.What are the different bean scopes in Spring ? Explain with an example ?

In Spring, creation of beans can be controlled by defining the scope of bean.  To define scope attribute ‘scope’ of <bean> tag is used. There are five types of bean scopes in Spring.

17.What is Aspect Oriented programming (AOP) ? Explain with an example ?

AOP is a programming technique used to manage cross-cutting concerns like logging, security and transaction management. To implement AOP we need to create aspects (classes) which contains cross-cutting functionality .

18. What is the difference between concerns and cross-cutting concerns ?

Concern is behavior which we want to have in a module of an application. Concern may be defined as a functionality we want to implement. Issues in which we are interested defines our concerns.

19. What is Aspect in Spring AOP? Explain with an example ?

Aspect defines the implementation of cross-cutting concern. We implement a cross-cutting functionality by creating an aspect. Aspect encapsulates our cross-cutting concern.

20.What is Advice in Spring AOP ? Explain with an example ?

Action performed by an aspect at a particular join point is called an Advice. Different types of advice are “around,” “before” ,”after”, “afterreturning” and “afterthrowing”.

21. What is Pointcut in Spring AOP ? Explain with an example ?

A pointcut is an expression/predicate which points to a join point. Pointcut defines where to hook the advice.

22.What is join point ? Explain with an example ?

Join point represents execution of a method where we want to hook the advice into.
Consider execution of a program and during this some methods are called say meth1(), meth2(), meth3().

23.What is Around advice ? Explain with an example ?

This advice is combination of before and after advices. It lets you do something before target method (join point) and some other things after the target method (join point).

24.Explain Spring MVC framework with an example ?

The MVC is a standard software architecture that aims to separate business logic from presentation logic, enabling the development, testing and maintenance of both isolated . (1) The user triggers an event through the UI (click a button on the page or something).
(2) The controller receives the event and coordinates how things will happen on the server side, i.e. the flow goes to the objects required to perform the business rule..

25.What is Controller in Spring MVC framework?
Ans: In a general way, Controller (‘c’ in mvc ) delivers access to the behavior of application which is usually defined by a service interface and acts as glue between core application and the web. It processes/interprets client data .

26.What is a front controller in Spring MVC ?

A front controller is defined as “a controller which handles all requests for a Web Application.” DispatcherServlet (actually a servlet) is the front controller in Spring MVC that intercepts every request and then dispatches/forwards requests to an appropriate controller.

27. What is SimpleFormController in Spring MVC and how to use it in your web application ?

It offers you form submission support. This can help in modeling forms and populating them with model/command object returned by the controller. After filling the form, it binds the fields, validates the model/command object, and passes the object back to the controller so that the controller can take appropriate action.

28.Why to override formBackingObject(HttpServletRequest request) method in Spring MVC?

You should override formBackingObject(HttpServletRequest request) if you want to provide view with model object data so that view can be initialized with some default values e.g. Consider in your form view.

29.What are the advantages of Spring MVC over Struts MVC ?

1. There is clear separation between models, views and controllers in Spring.
2. Spring’s MVC is very versatile and flexible based on interfaces but Struts forces Actions and Form object into concrete inheritance.
3. Spring provides both interceptors and controllers..

30.Difference between FileSystemResource and ClassPathResource ?

In FileSystemResource you need to give path of spring-config.xml (Spring Configuration) file relative to your project or the absolute location of the file.
You can get this by right-clicking the spring-config.xml.

31.Difference between BeanFactory and ApplicationContext ?

BeanFactory instantiates beans lazily i.e. Beans are instantiated when you get them from BeanFactory not on loading BeanFactory.

32.What makes J2EE appropriate for dispersed/distributed multitiered WEB Applications ?

J2EE platform follows a multi-tiered distributed application model. Application logic is distributed into components according to role, and the different application components that make up a J2EE application are installed on different machines depending on the tier in the multi-tiered J2EE environment to which the application component belongs. The J2EE application parts are:
• Client-tier component runs on the client machine.
• Web-tier component runs on the J2EE server.
• Business-tier component runs on the J2EE server.
• Enterprise Information System tier software runs on the EIS server.

33. What are different components of J2EE application ?

A J2EE component is a self-contained functional software entity that is combined into a J2EE application with its related classes, files and intracts with other components. The J2EE defines the given below J2EE components:
• Application clients and applets act as client components.
• Java Servlet and JavaServer Pages act as web components.
• Enterprise JavaBeans(EJB) components act as business components.
• Resource adapter components delivered by EIS and tool vendors.

34 What is Enterprise JavaBeans component ?

Enterprise JavaBeans components comprises Business code, which is logic
that fulfill the requirements of a particular business domain such as retail, banking , telecom or finance. All business code is enclosed inside an Enterprise Bean which gets data from client, processes it, and sends it to the enterprise information system tier for persistence. An enterprise bean also fetches data from storage, processes it and sends it back to the client program.

35.What is the container ?

It is the interface between a component and the low-level platform centric functionality that supports the component. Container contains and manages the execution and lifecycle of components. Before a Web, enterprise bean, or application client component can be executed, it must be integrated into a J2EE application and deployed into its container.

36.What is deployment descriptor ?

A deployment descriptor is an XML text-based file with an .xml extension that describes about component’s deployment settings. A J2EE application and its every modules has its own deployment descriptor. For example, an enterprise bean module deployment descriptor describes transaction settings and security authorizations
settings for an enterprise bean. As deployment descriptor information is declarative, it can be modified without altering the bean source code. At run time, the J2EE server reads the deployment descriptor and executes component accordingly.

37.What are the implicit objects ?

Implicit objects are objects which are created by the web container and contain information about a particular request, page, or application. Implicit objects are : request, response, pageContext, session, application, out, config, page, exception.

38.How does JSP handle run-time exceptions?

You can use the errorPage attribute of the page directive to handle uncaught run-time exceptions and so automatically forwarded to an error processing page. For example: <%@ page errorPage=”error.jsp” %> redirects the browser to page error.jsp if an uncaught exception occured during request processing. Within error.jsp, if you indicate that it is an error-processing page, via the directive: <%@ page isErrorPage=”true” %> then Throwable object describing the exception may be accessed within the error page via the ‘exception’ implicit object. Note: You must always use a relative URL as the value for the errorPage attribute.

39.What is a Declaration ?

A declaration has one or more variables or methods declared for use later in the JSP source file.
It must contain at least one declarative statement. Any number of variables or methods within one declaration tag, as long as they are separated by semicolons.
<%! int i = 0; %>
<%! int a, b, c; %>

40.What is a Scriptlet ?

A scriptlet can contain any number of language statements, variable or method declarations/defination, or expressions which are valid in the page scripting language.Within scriptlet tags, you can
Declare variables or methods .
Write expressions that are valid in the page scripting language.
Use JSP implicit objects or any object declared with a <jsp:useBean> tag.
You must write plain text, HTML-encoded text, or other JSP tags outside the scriptlet tag.
Scriptlets are executed by JSP engine request time. If the scriptlet generates output, the output is saved in the out object.

41. What is a output comment ?

A comment which is sent to the client in the viewable page source. The JSP engine treats an output comment as uninterpreted HTML text, returning the comment in the HTML output sent to the client. Comment can be seen by viewing the page source from your Web browser.
JSP Syntax
<!– comment [ <%= expression %> ] –>
Example 1
<!– commnet sent to client on
<%= (new java.util.Date()).toLocaleString() %>
–>
Displays in the page source:
<!– commnet sent to client on January 20, 2012 –>

42.What is a Hidden Comment ?

A comments that is not sent to the client. The JSP engine ignores a hidden comment, and does not process any of the code within hidden comment. A hidden comment is not sent to the client, either in the shown JSP page or the HTML page source. The hidden comment is useful when you don’t want to execute some part of your JSP page.
You can use any characters in the comment except the closing –%> tag. If you want to use –%> in your comment, you can escape it by typing –%\>.
JSP Syntax
<%– comment –%>
Examples
<html>
<head><title>A Hidden Comment </title></head>
<body>
<%– This comment is not visible to the client in the page source –%>
</body>
</html>

43.Explain the life cycle methods of a Servlet ?

The javax.servlet.Servlet interface defines the three methods called as life-cycle method.
public void init(ServletConfig config) throws ServletException
public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException
public void destroy()
First the servlet is constructed, then servlet is initialized wih the init() method.
Any request from client is handled by the service() method before delegating to the doGet()/doPost() methods in the case of HttpServlet.
Ffter service method finished , container removes servlet out of service, it calls the servlet’s destroy() method.

44.Differentiate between the getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface and javax.servlet.ServletContext interface?

The getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface takes parameter the path to the resource to be included or forwarded to, that can be relative to the request of the calling servlet. If the path begins with a “/” it is interpreted as relative to the current context root.
The getRequestDispatcher(String path) method of javax.servlet.ServletContext interface cannot take relative paths. All path must sart with a “/” and are interpreted as relative to current context root.

45.Describe the directory structure of a web application ?

The directory structure of a web application composed of two parts.
A private directory WEB-INF
A public resource directory which contains public resource folder.
WEB-INF folder consists of
• web.xml (deployment descriptor)
• classes directory containing .class files
• lib directory containing jar files

46.How do I prevent the output of my JSP or Servlet pages from being cached by the browser?

Just write the following scriptlet code at the beginning of your JSP pages to prevent them from being cached at the browser. You need both the statements to take care of some of the older browser versions.
<%
response.setHeader(“Cache-Control”,”no-store”); //HTTP 1.1
response.setHeader(“Pragma”,”no-cache”); //HTTP 1.0
response.setDateHeader (“Expires”, 0); //prevents caching at the proxy server
%>

47.How a servlet is preinitialized ?

A container does not initialize the servlets on its start up, it initializes a servlet when it receives a request for that servlet first time that is called lazy loading. A servlet can be loaded at the start up of the container by using <load-on-startup> 1</load-on-startup> element, which can be specified in web.xml. This process of loading a servlet at start up of container is called preloading or preinitializing a servlet.

48.What is the difference between ServletContext and ServletConfig ?

ServletContext: Defines a set of methods which help servlet to communicate with its servlet container, for example, to get the MIME type , dispatch requests, or write to a log file.The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized . The ServletContext object signifies the context for the whole Web application in which a servlet is deployed, and contains initialisation parameters that are available to all servlets in the application.
ServletConfig: ServletConfig is a servlet configuration object that is used by a servlet container used to pass information/data to a servlet during initialization. All of its initialization parameters can ONLY be set in deployment descriptor.The ServletConfig object represents the configuration for a single specific servlet. The ServletConfig parameters are ment for a particular servlet and are unknown to other servlets.

49.Explain the life cycle methods of a Servlet ?

The javax.servlet.Servlet interface defines the three methods called as life-cycle method.
public void init(ServletConfig config) throws ServletException
public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException
public void destroy()
First the servlet is constructed, then servlet is initialized wih the init() method.
Any request from client is handled by the service() method before delegating to the doGet()/doPost() methods in the case of HttpServlet.
Ffter service method finished , container removes servlet out of service, it calls the servlet’s destroy() method.

50.Differentiate between the getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface and javax.servlet.ServletContext interface?

The getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface takes parameter the path to the resource to be included or forwarded to, that can be relative to the request of the calling servlet. If the path begins with a “/” it is interpreted as relative to the current context root.
The getRequestDispatcher(String path) method of javax.servlet.ServletContext interface cannot take relative paths. All path must sart with a “/” and are interpreted as relative to current context root.

51 Explain ServletContext ?

ServletContext interface act as a window for a servlet to view it’s surroundings . A servlet can use this interface to get information such as initialization parameters for the web application or servlet container. Every web application has only one ServletContext that is accessible to all active resource of that application.

52 How a servlet is preinitialized ?

A container does not initialize the servlets on its start up, it initializes a servlet when it receives a request for that servlet first time that is called lazy loading. A servlet can be loaded at the start up of the container by using <load-on-startup> 1</load-on-startup> element, which can be specified in web.xml. This process of loading a servlet at start up of container is called preloading or preinitializing a servlet.

53 What is the difference between doGet() and doPost() ?

doGet is called when a HTTP GET request is made. doGet() is called when users click on a link, or enter a URL into the browser’s address bar. It also happens with some HTML FORMs (those with METHOD=”GET” specified in the FORM tag). In doGet Method the parameters are appended to the URL and sent along with header information.
Maximum size of data that can be sent is limited. Parameters sent are not encrypted . DoGet is faster if we set the response content length since the same connection is used. Thus increasing the performance
doPost is when a HTTP POST request is made. This happens with HTML FORMs (those with METHOD=”POST” specified in the FORM tag). In doPost method , form data is sent in separate line in the body. Data that can be sent is not limited. Parameters are sent in encrypted form. DoPost is slower compared to doGet since doPost does not write the content response length.

54.Difference between forward and sendRedirect ?

Both forward and sendRedirect methods are used to transfer the control from one resource to another.
forward : When you transfer the control to another resource by invoking a forward request, the request is sent to another resource on the server, without the client being informed about the fact that a different resource is going to process the request. This process occurs completely with in the web container, browser or client don’t perform any role in this. When the forward request is done, the original request and response objects are transferred and in the other resource to which the control is passed can get these objects. In forward request URL in the browser does not change.
sendRedirect : In sendRedirect the transfer of control task is delegated to the browser by the container. A header information is sent back to the browser / client when sendRedirect is invoked. This header information contains the resource url to be redirected by the browser. Then the browser make a new request to the given url and URL in browser gets changed. As it is a new request, the old request and response object is lost.

55.What are container services ?

A container act as a runtime support of a system-level entity. Containers provide components with different services such as lifecycle management, security, deployment, and threading.

56.What is the web container ?

Servlet and JSP containers are called Web containers. It manages the execution and lifecycle of JSP page and servlet components for J2EE applications. Web components and their container

57.What is Applet container ?

It manages the execution of applets, comprises of a Web browser and Java Plugin assembled on the client together.

58. What is a thin client ?

A thin client is a lightweight interface to the application that does not have such operations like query databases, execute complex business rules, or connect to legacy applications. A thin client is portion of a network, and the client software or computer acts as an interface, while the network server computer performs all the actual work.

59.What is J2EE(Java2 enterprise edition) ?

J2EE is platform for developing and deploying enterprise Web applications. The J2EE platform contains a set of services, application programming interfaces (APIs), and protocols that offer the functionality for developing multi-tiered, web-based applications.

60.Are J2EE applications only a web-based ?

No, It depends on type of application that client wants to have. A J2EE application can be both web-based or non web-based. If an application runs on the client machine, it is a non web-based J2EE application.

61.Is HTML page a web component ?

No. Static HTML pages and applets are bundled into web components during application assembly, but are not supposed web components by the J2EE specification. Even the server-side utility classes are not supposed web components, either.

62.What is the EAR file ?

An EAR file is a standard JAR file having .ear extension, named from Enterprise ARchive file. A J2EE application with all of its modules is delivered in EAR file.

63.What are the different ways for session tracking ?

Cookies, HttpSession, URL rewriting, Hidden form fields

64.What is Spring?

Spring is an open source framework created to address the complexity of enterprise application development. One of the chief advantages of the Spring framework is its layered architecture, which allows you to be selective about which of its components you use while also providing a cohesive framework for J2EE application development.

65.What are the different types of AutoProxying?

BeanNameAutoProxyCreator.
DefaultAdvisorAutoProxyCreator.
Metadata autoproxying.

66.What is an Introduction in AOP?

An introduction allows the user to add new methods or attributes to an existing class. This can then be introduced to an existing class without having to change the structure of the class, but give them the new behavior and state.

67.What is a Target?

A target is the class that is being advised. The class can be a third party class or your own class to which you want to add your own custom behavior. By using the concepts of AOP, the target class is free to center on its major concern, unaware to anyadvice that is being applied.

68. What is a Proxy?

A proxy is an object that is created after applying advice to a target object. When you think of client objects the target object and the proxy object are the same.

69. What is meant by Weaving?

The process of applying aspects to a target object to create a new proxy object is called as Weaving. The aspects are woven into the target object at the specified joinpoints.

70. What are the different points where weaving can be applied?

? Compile Time
? Classload Time
? Runtime

71.What are the advantages of Spring framework?

The advantages of Spring are as follows:
1.Spring has layered architecture. Use what you need and leave you don't need now.
2. Spring Enables POJO Programming. There is no behind the scene magic here. POJO programming enables continuous integration and testability.
3.Dependency Injection and Inversion of Control Simplifies JDBC
4. Open source and no vendor lock-in.

72. What are different types of Autowire types?

There are four different types by which autowiring can be done.
1.byName
2.byType
3.constructor
4.autodetect

73.What is an Aspect?

An aspect is the cross-cutting functionality that you are implementing. It is the aspect of your application you are modularizing. An example of an aspect is logging. Logging is something that is required throughout an application. However, because applications tend to be broken down into layers based on functionality, reusing a logging module through inheritance does not make sense. However, you can create a logging aspect and apply it throughout your application using AOP.

74. What is a Jointpoint?

A joinpoint is a point in the execution of the application where an aspect can be plugged in. This point could be a method being called, an exception being thrown, or even a field being modified. These are the points where your aspect’s code can be inserted into the normal flow of your application to add new behavior.

75. What is an Advice?

Advice is the implementation of an aspect. It is something like telling your application of a new behavior. Generally, and advice is inserted into an application at joinpoints.

76. What is a Pointcut?

A pointcut is something that defines at what joinpoints an advice should be applied. Advices can be applied at any joinpoint that is supported by the AOP framework. These Pointcuts allow you to specify where theadvice can be applied.

77. What is Significance of JSF- Spring integration?

Spring - JSF integration is useful when an event handler wishes to explicitly invoke the bean factory to create beans on demand, such as a bean that encapsulates the business logic to be performed when a submit button is pressed.

78.How to integrate your Struts application with Spring?

To integrate your Struts application with Spring, we have two options:
1.Configure Spring to manage your Actions as beans, using the ContextLoaderPlugin, and set their dependencies in a Spring context file.
2.subclass Spring's ActionSupport classes and grab your Spring-managed beans explicitly using a getWebApplicationContext() method.

79. What are the important beans lifecycle methods?

There are two important bean lifecycle methods. The first one is setup which is called when the bean is loaded in to the container. The second method is the teardown method which is called when the bean is unloaded from the container.

80. What are Inner Beans?

When wiring beans, if a bean element is embedded to a property tag directly, then that bean is said to the Inner Bean. The drawback of this bean is that it cannot be reused anywhere else.

81.What are the different types of bean injections?

There are two types of bean injections.
1. By setter
2. By constructor

82. What is AOP Alliance?

AOP Alliance is an open-source project whose goal is to promote adoption of AOP and interoperability among different AOP implementations by defining a common set of interfaces and components.

83. What is Spring configuration file?

Spring configuration file is an XML file. This file contains the classes information and describes how these classes are configured and introduced to each other.

84.What does a simple spring application contain?

These applications are like any Java application. They are made up of several classes, each performing a specific purpose within the application. But these classes are configured and introduced to each other through an XML file. This XML file describes how to configure the classes, known as theSpring configuration file.

85.What is XMLBeanFactory?

BeanFactory has many implementations in Spring. But one of the most useful one is org.springframework.beans.factory.xml.XmlBeanFactory, which loads its beans based on the definitions contained in an XML file. To create an XmlBeanFactory, pass a java.io.InputStream to the constructor. The InputStream will provide the XML to the factory. For example, the following code snippet uses a java.io.FileInputStream to provide a bean definition XML file to XmlBeanFactory.

86.Explain Bean lifecycle in Spring framework?

1. The spring container finds the bean’s definition from the XML file and instantiates the bean.
2. Using the dependency injection, spring populates all of the properties as specified in the bean definition.
3. If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID.
4. If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of itself.
5. If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization() methods will be called.
6. If an init-method is specified for the bean, it will be called.
7. Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called

87.What is Application context module?

The Application context module makes spring a framework. This module extends the concept of BeanFactory, providing support for internationalization (I18N) messages, application lifecycle events, and validation. This module also supplies many enterprise services such JNDI access, EJB integration, remoting, and scheduling. It also provides support to other framework.

88. What is AOP module?

The AOP module is used for developing aspects for our Spring-enabled application. Much of the support has been provided by the AOP Alliance in order to ensure the interoperability between Spring and other AOP frameworks. This module also introduces metadata programming to Spring. Using Spring’s metadata support, we will be able to add annotations to our source code that instruct Spring on where and how to apply aspects.

89.What is JDBC abstraction and DAO module?

Using this module we can keep up the database code clean and simple, and prevent problems that result from a failure to close database resources. A new layer of meaningful exceptions on top of the error messages given by several database servers is bought in this module. In addition, this module uses Spring’s AOP module to provide transaction management services for objects in a Spring application.

90.What are object/relational mapping integration module?

Spring also supports for using of an object/relational mapping (ORM) tool over straight JDBC by providing the ORM module. Spring provide support to tie into several popular ORM frameworks, including Hibernate, JDO, and iBATIS SQL Maps. Spring’s transaction management supports each of these ORM frameworks as well as JDBC.

91.What is web module?

This module is built on the application context module, providing a context that is appropriate for web-based applications. This module also contains support for several web-oriented tasks such as transparently handling multipart requests for file uploads and programmatic binding of request parameters to your business objects. It also contains integration support with Jakarta Struts.

92.What do you mean by Bean wiring?

The act of creating associations between application components (beans) within the Spring container is reffered to as Bean wiring.

93.What do you mean by Auto Wiring?

The Spring container is able to autowire relationships between collaborating beans. This means that it is possible to automatically let Spring resolve collaborators (other beans) for your bean by inspecting the contents of the BeanFactory. The autowiring functionality has five modes.
no
byName
byType
constructor
autodirect

94.What is DelegatingVariableResolver?

Spring provides a custom JavaServer Faces VariableResolver implementation that extends the standard Java Server Faces managed beans mechanism which lets you use JSF and Spring together. This variable resolver is called as DelegatingVariableResolver

95.What are the different modules in Spring framework?

1.The Core container module
2.Application context module
3.AOP module (Aspect Oriented Programming)
4.JDBC abstraction and DAO module
5.O/R mapping integration module (Object/Relational)
6.Web module
7.MVC framework module

96.What is the Core container module?

This module is provides the fundamental functionality of the spring framework. In this module BeanFactory is the heart of any spring-based application. The entire framework was built on the top of this module. This module makes the Spring container.

97.What is difference between LookupDispatchAction and DispatchAction?

The difference between LookupDispatchAction and DispatchAction is that the actual method that gets called in LookupDispatchAction is based on a lookup of a key value instead of specifying the method name directly.

98What is SwitchAction?

The SwitchAction class provides a means to switch from a resource in one module to another resource in a different module. SwitchAction is useful only if you have multiple modules in your Struts application. The SwitchAction class can be used as is, without extending.

99.What is DynaActionForm?

A specialized subclass of ActionForm that allows the creation of form beans with dynamic sets of properties (configured in configuration file), without requiring the developer to create a Java class for each type of form bean.

100.How to display validation errors on jsp page?

<html:errors/> tag displays all the errors. <html:errors/> iterates over ActionErrors request attribute.

101.What is the use of ForwardAction?

The ForwardAction class is useful when you’re trying to integrate Struts into an existing application that uses Servlets to perform business logic functions. You can use this class to take advantage of the Struts controller and its functionality, without having to rewrite the existing Servlets. Use ForwardAction to forward a request to another resource in your application, such as a Servlet that already does business logic processing or even another JSP page. By using this predefined action, you don’t have to write your own Action class. You just have to set up the struts-config file properly to use ForwardAction.

102.What is IncludeAction?

The IncludeAction class is useful when you want to integrate Struts into an application that uses Servlets. Use the IncludeAction class to include another resource in the response to the request being processed.

103.What is the difference between ForwardAction and IncludeAction?

The difference is that you need to use the IncludeAction only if the action is going to be included by another action or jsp. Use ForwardAction to forward a request to another resource in your application, such as a Servlet that already does business logic processing or even another JSP page.

104.What is LookupDispatchAction?

The LookupDispatchAction is a subclass of DispatchAction. It does a reverse lookup on the resource bundle to get the key and then gets the method whose name is associated with the key into the Resource Bundle.

105.What is the use of LookupDispatchAction?

LookupDispatchAction is useful if the method name in the Action is not driven by its name in the front end, but by the Locale independent key into the resource bundle. Since the key is always the same, the LookupDispatchAction shields your application from the side effects of I18N.



-------------------------------------

Also Read:





































 

0 comments:

Post a Comment