SlideShare a Scribd company logo
JAVA Interview Questions Part-2
JAVA J2EE Training
51. What are considered as a web component?
Java Servlet and Java Server Pages technology components are web components.
Servlets are Java programming language that dynamically receive requests and
make responses. JSP pages execute as servlets but allow a more natural approach
to creating static content.
52. Define Hash table?
Hash Table is just like Hash Map or Collection having unique key value pairs. Hash
table is a collection of Synchronized object. It does not allow duplicate values but it
allows null values.
53. What is Hibernate?
Hibernate is a open source object-relational mapping and query service. In
hibernate we can write HQL instead of SQL which save developers to spend more
time on writing the native SQL. Hibernate has more powerful association,
inheritance, polymorphism, composition, and collections. It is a beautiful approach
for persisting into database using the java objects. Hibernate also allows you to
express queries using java-based criteria.
54. What is ORM?
ORM stands for Object-Relational mapping. The objects in a Java class which is
mapped in to the tables of a relational database using the metadata that describes
the mapping between the objects and the database. It works by transforming the
data from one representation to another.
55. Difference between Proxy and Adapter?
Adapter object has a different input than the real subject whereas Proxy object has
the same input as the real subject. Proxy object is such that it should be placed as
it is in place of the real subject.
56. What is MVC?
Model-View-Controller is a design pattern wherein Model holds the business logic
, Controller controls the flow and View takes care of the presentation part of web
application.
57. What is dependency injection or IOC?
It's a mechanism of passing object creation to an external component wherein
dependent objects are identified and created using configuration.
58. What is bean auto wiring?
The Spring container is able to auto wire 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 without using <constructor-arg> and <property> element.
59. What are the different types of IOC (dependency injection)?
Constructor Injection (e.g. Pico container, Spring etc): Dependencies are provided
as constructor parameters.
Setter Injection (e.g. Spring): Dependencies are assigned through JavaBeans
properties (ex: setter methods).
Interface Injection (e.g. Avalon): Injection is done through an interface.
Note: Spring supports only Constructor and Setter Injection
60. What are the advantages of Spring framework?
The advantages of Spring are as follows:
Spring has layered architecture. Use what you need and leave you don't need now.
Spring Enables POJO Programming. There is no behind the scene magic here. POJO
programming enables continuous integration and testability.
Dependency Injection and Inversion of Control Simplifies JDBC
Open source and no vendor lock-in.
61. What are the common implementations of the Application Context?
The three commonly used implementation of 'Application Context' are,
ClassPathXmlApplicationContext : It Loads context definition from an XML file
located in the classpath, treating context definitions as classpath resources. The
application context is loaded from the application's classpath by using the code.
ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
FileSystemXmlApplicationContext : It loads context definition from an XML file in
the filesystem. The application context is loaded from the file system by using the
code.
ApplicationContext context = new FileSystemXmlApplicationContext("bean.xml");
XmlWebApplicationContext : It loads context definition from an XML file
contained within a web application.
62. 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.
63. 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.
64. What are the ways to access Hibernate using Spring?
There are two approaches to Spring’s Hibernate integration:
Inversion of Control with a HibernateTemplate and Callback
Extending HibernateDaoSupport and Applying an AOP Interceptor.
65. How the AOP used in Spring?
AOP is used in the Spring Framework: To provide declarative enterprise services,
especially as a replacement for EJB declarative services. The most important such
service is declarative transaction management, which builds on the Spring
Framework's transaction abstraction. To allow users to implement custom aspects,
complementing their use of OOP with AOP.
66. What is Session Tracking?
Session simply means a particular interval of time.
Session Tracking is a way to maintain state of an user. Http protocol is a stateless
protocol. Each time user requests to the server, server treats the request as the
new request. So we need to maintain the state of a user to recognize to particular
user.
67. How is a typical spring implementation look like?
For a typical Spring Application we need the following files:
An interface that defines the functions.
An Implementation that contains properties, its setter and getter methods,
functions etc., Spring AOP (Aspect Oriented Programming)
A XML file called spring configuration file.
Client program that uses the function.
68. What is Java Server Faces (JSF) - spring integration mechanism?
Spring provides a custom JavaServer Faces VariableResolver implementation that
extends the standard JavaServer Faces managed beans mechanism. When asked to
resolve a variable name, the following algorithm is performed.
69. 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.
70. How to integrate your Struts application with spring?
To integrate your Struts application with spring, we have two options:
Configure spring to manage your Actions as beans, using the ContextLoaderPlugin,
and set their dependencies in a spring context file.
Subclass Spring's ActionSupport classes and grab your Spring-managed beans
explicitly using a getWebApplicationContext() method.
71. How to integrate spring and Hibernate?
Spring and Hibernate can integrate using spring’s SessionFactory called
LocalSessionFactory. The integration process is of 3 steps.
Configure Hibernate mappings.
Configure Hibernate properties.
Wire dependant object to SessionFactory.
72. What are the ways to access Hibernate using Spring?
There are two ways to access Hibernate from Spring:
Through Hibernate Template.
Subclassing HibernateDaoSupport
Extending HibernateDaoSupport and Applying an AOP Interceptor
73. Why most users of the Spring Framework choose declarative transaction
management?
Most users of the Spring Framework choose declarative transaction management
because it is the option with the least impact on application code, and hence is
most consistent with the ideals of a non-invasive lightweight container.
74. When to use programmatic and declarative transaction management?
Programmatic transaction management is usually a good idea only if you have a
small number of transactional operations.
On the other hand, if your application has numerous transactional operations,
declarative transaction management is usually worthwhile. It keeps transaction
management out of business logic, and is not difficult to configure.
75. Explain about the Spring DAO support?
The Data Access Object (DAO) support in Spring is aimed at making it easy to work
with data access technologies like JDBC, Hibernate or JDO in a consistent way. This
allows one to switch between the persistence technologies fairly easily and it also
allows one to code without worrying about catching exceptions that are specific to
each technology.
76.What are the exceptions thrown by the Spring DAO classes?
Spring DAO classes throw exceptions which are subclasses of
DataAccessException(org.springframework.dao.DataAccessException).Spring
provides a convenient translation from technology-specific exceptions like
SQLException to its own exception class hierarchy with the DataAccessException as
the root exception. These exceptions wrap the original exception.
77. What is SQLExceptionTranslator?
SQLExceptionTranslator, is an interface to be implemented by classes that can
translate between SQLExceptions and Spring's own data-access-strategy-agnostic
org.springframework.dao.DataAccessException.
78. What is Spring's JdbcTemplate ?
Spring's JdbcTemplate is central class to interact with a database through
JDBC. JdbcTemplate provides many convenience methods for doing things such as
converting database data into primitives or objects, executing prepared and
callable statements, and providing custom database error handling.
JdbcTemplate template = new JdbcTemplate(myDataSource);
79. What is PreparedStatementCreator ?
PreparedStatementCreator:
Is one of the most commonly used interfaces for writing data to database.
Has one method – createPreparedStatement(Connection)
Responsible for creating a PreparedStatement.
Does not need to handle SQLExceptions.
80. What is Application Context?
A bean factory is fine to simple applications, but to take advantage of the full
power of the Spring framework, you may want to move up to Springs more
advanced container, the application context. On the surface, an application context
is same as a bean factory.Both load bean definitions, wire beans together, and
dispense beans upon request. But it also provides:
* A means for resolving text messages, including support for internationalization.
* A generic way to load file resources.
* Events to beans that are registered as listeners.
81. What are the types of Dependency Injection Spring supports?
Setter Injection: Setter-based DI is realized by calling setter methods on your
beans after invoking a no-argument constructor or no-argument static factory
method to instantiate your bean.
Constructor Injection: Constructor-based DI is realized by invoking a constructor
with a number of arguments, each representing a collaborator.
82. What are the exceptions thrown by the Spring DAO classes ?
Spring DAO classes throw exceptions which are subclasses of
DataAccessException(org.springframework.dao.DataAccessException).Spring
provides a convenient translation from technology-specific exceptions like
SQLException to its own exception class hierarchy with the DataAccessException as
the root exception. These exceptions wrap the original exception.
83. What is Spring's JdbcTemplate ?
Spring's JdbcTemplate is central class to interact with a database through JDBC.
JdbcTemplate provides many convenience methods for doing things such as
converting database data into primitives or objects, executing prepared and
callable statements, and providing custom database error handling.
JdbcTemplate template = new JdbcTemplate (myDataSource);
84. Explain the three different methods which are provided by the Namespace
Handler interface?
The three different methods which are provided by the name space handler
interface are:
1) Init() is used to allow initialization for name space handler.
2) BeanDefinition parse is used when a Spring encounters a top level element.
3) BeanDefinitionHandler is used when spring encounters an attribute.
85. Which of the beans available in EJB 3 are only called by clients ?
Session and Singleton (EJB 3.1) beans are the ones who encapsulate the business
logic which is why it is the only bean which is called by clients. Other beans like
MDB and Entity beans are called by session and singleton beans to complete the
business requirement.
86. Why is it so to make the session beans into two parts one with interface and
the other as implementation to the interface? Or why session beans should be
used through business interface? (EJB 3.0 Specific).
This approach promotes loose coupling since implementation classes can easily be
swapped out without a lot of code changes. But in recent EJB 3.1 specification you
don't need to implement a business interface for faster development.
87. What is business interface?
An interface through which a client invokes the bean is called a business
interface. There are three types of business interfaces available in EJB 3 : Local,
Remote and WebService
88. Can we have instance fields in Stateless session bean?
Yes. A stateless session bean can have instance field, BUT not for storing state
information as opposed to Stateful beans. There may be a need of storing certain
shareable resources like data source, JMS source etc, which will be used in the
exposed method. So it is perfectly safe to have instance fields in the Stateless
session beans.
89. Can you inject Stateful beans into stateless session bean or Servlet?
Yes!!. Nobody stops you to inject Stateful beans into stateless session bean or a
Servlet. Let’s take a Servlet and inject (definitely as a field in Servlet) a Stateful
bean; What happens? Container creates a single instance of a Servlet, so the
instance field of Servlet ( which is a Stateful Bean ) injected , is shared among
clients.It will lead to drastic data inconsistency ( stored in Stateful bean ) being
shared by clients. And this is no different for a Stateful bean injected into stateless
bean. So you must AVOID injecting into stateless beans and Servlets. Please don't
ask how do you access or make use of Stateful bean in Stateless or Servlet.The
answer is JNDI inside the methods of Stateless and doGet() or doPost() of Servlet.
90. What are Pull-MVC and push-MVC based architecture ? Whicharchitecture
does Struts2 follow?
Pull-MVC and Push-MVC are better understood with how the view layer is getting
data i.e. Model to render. In case of Push-MVC the data( Model) is constructed and
given to the view layer by the Controllers by putting it in the scoped variables like
request or session. Typical example is Spring MVC and Struts1. Pull-MVC on the
other hand puts the model data typically constructed in Controllers are kept in a
common place i.e. in actions, which then gets rendered by view layer. Struts2 is a
Pull-MVC based architecture, in which all data is stored in Value Stack and
retrieved by view layer for rendering.
91. Are Interceptors in Struts2 thread safe?
No, Unlike Struts2 action, Interceptors are shared between requests, so thread
issues will come if not taken care of
92. Are Interceptors and Filters different? , If yes then how?
Apart from the fact that both Interceptors and filters are based on intercepting
filter,there are few differences when it comes to Struts2.
Filters: (1)Based on Servlet Specification (2)Executes on the pattern matches on
the request.(3) Not configurable method calls
Interceptors: (1)Based on Struts2. (2)Executes for all the request qualifies for a
front controller( A Servlet filter ).And can be configured to execute additional
interceptor for a particular action execution.(3)Methods in the Interceptors can be
configured whether to execute or not by means of excludemethods or
includeMethods. ( see tutorial on this Controlling Interceptor Behavior)
93. Which class is the front-controller in Struts2?
The class "org.apache.struts2.dispatcher.FilterDispatcher " is the front controller in
Struts2. In recent time Struts 2.1.3 this class is deprecated and new classes are
introduced to do the job.
94. What is the role of Action/ Model?
Actions in Struts are POJO, is also considered as a Model. The role of Action are to
execute business logic or delegate call to business logic by the means of action
methods which is mapped to request and contains business data to be used by the
view layer by means of setters and getters inside the Action class and finally helps
the framework decide which result to render.
95. What is the relation between ValueStack and OGNL?
A ValueStack is a place where all the data related to action and the action itself is
stored. OGNL is a mean through which the data in the ValueStack is manipulated.
96. What is the difference between Action and ActionSupport?
Action is interface defines some string like SUCCESS,ERROR etc and an execute()
method. For convenience Developer implement this interface to have access to
String field in action methods. ActionSupport on other hand implements Action
and some other interfaces and provides some feature like data validation and
localized error messaging when extended in the action classes by developers
97. Who loads the struts.xml file? Which Struts2 API loads the struts.xml file?
In Struts2 FilterServlet is the responsible class for loading struts.xml file as we
deploy the application on the container. Unlike Servlet (as with Struts1) needs
the load-on-startup tag to load the front controller,a filter doesn't need to have
load on startup tag to be loaded as the application is deployed. As with servlet
specification a filter is loaded/executed as the application starts up.
98. What is JDBC Driver interface?
The JDBC Driver interface provides vendor-specific implementations of the
abstract classes provided by the JDBC API. Each vendor driver must provide
implementations of the java.sql.Connection, Statement, PreparedStatement,
CallableStatement, ResultSet and Driver.
99. What is the jspInit() method?
The jspInit() method of the javax.servlet.jsp.JspPage interface is similar to the init()
method of servlets. This method is invoked by the container only once when a JSP
page is initialized. It can be overridden by a page author to initialize resources such
as database and network connections, and to allow a JSP page to read persistent
configuration data.
100. What is the _jspService() method?
The _jspService() method of the javax.servlet.jsp.HttpJspPage interface is invoked
every time a new request comes to a JSP page. This method takes the
HttpServletRequest and HttpServletResponse objects as its arguments. A page
author cannot override this method, as its implementation is provided by the
container.
Ad

More Related Content

What's hot (16)

Java questions with answers
Java questions with answersJava questions with answers
Java questions with answers
Kuntal Bhowmick
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
Kuntal Bhowmick
 
Java j2ee interview_questions
Java j2ee interview_questionsJava j2ee interview_questions
Java j2ee interview_questions
ppratik86
 
Best interview questions
Best interview questionsBest interview questions
Best interview questions
Thesis Scientist Private Limited
 
Technical interview questions
Technical interview questionsTechnical interview questions
Technical interview questions
Soba Arjun
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
SynergisticMedia
 
Design pattern
Design patternDesign pattern
Design pattern
Mallikarjuna G D
 
Spring andspringboot training
Spring andspringboot trainingSpring andspringboot training
Spring andspringboot training
Mallikarjuna G D
 
Spring - Part 3 - AOP
Spring - Part 3 - AOPSpring - Part 3 - AOP
Spring - Part 3 - AOP
Hitesh-Java
 
Hibernate Advance Interview Questions
Hibernate Advance Interview QuestionsHibernate Advance Interview Questions
Hibernate Advance Interview Questions
Rudra Garnaik, PMI-ACP®
 
Hibernate notes
Hibernate notesHibernate notes
Hibernate notes
Rajeev Uppala
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview Questions
Syed Shahul
 
Top 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersTop 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed Answers
Whizlabs
 
Hibernate
HibernateHibernate
Hibernate
Mallikarjuna G D
 
Spring & hibernate
Spring & hibernateSpring & hibernate
Spring & hibernate
Santosh Kumar Kar
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
Hitesh-Java
 
Java questions with answers
Java questions with answersJava questions with answers
Java questions with answers
Kuntal Bhowmick
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
Kuntal Bhowmick
 
Java j2ee interview_questions
Java j2ee interview_questionsJava j2ee interview_questions
Java j2ee interview_questions
ppratik86
 
Technical interview questions
Technical interview questionsTechnical interview questions
Technical interview questions
Soba Arjun
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
SynergisticMedia
 
Spring andspringboot training
Spring andspringboot trainingSpring andspringboot training
Spring andspringboot training
Mallikarjuna G D
 
Spring - Part 3 - AOP
Spring - Part 3 - AOPSpring - Part 3 - AOP
Spring - Part 3 - AOP
Hitesh-Java
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview Questions
Syed Shahul
 
Top 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersTop 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed Answers
Whizlabs
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
Hitesh-Java
 

Viewers also liked (13)

Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1
Mindsmapped Consulting
 
Hope For Tomorrow 22 June 2015--final draft
Hope For Tomorrow 22 June 2015--final draftHope For Tomorrow 22 June 2015--final draft
Hope For Tomorrow 22 June 2015--final draft
Sandra Robinson
 
Skelton.MISL2015
Skelton.MISL2015Skelton.MISL2015
Skelton.MISL2015
Stephanie Skelton
 
MARKET SHARE OF WOMEN & CHILDREN HEALTH DRINKS
MARKET SHARE OF WOMEN & CHILDREN HEALTH DRINKSMARKET SHARE OF WOMEN & CHILDREN HEALTH DRINKS
MARKET SHARE OF WOMEN & CHILDREN HEALTH DRINKS
MADHU SHREE
 
Greater Curtin Information Memorandum 26 April 2016
Greater Curtin Information Memorandum 26 April 2016Greater Curtin Information Memorandum 26 April 2016
Greater Curtin Information Memorandum 26 April 2016
Tim Urquhart
 
ORL515 Hope for Tomorrow 06-22-15 Final
ORL515 Hope for Tomorrow 06-22-15 FinalORL515 Hope for Tomorrow 06-22-15 Final
ORL515 Hope for Tomorrow 06-22-15 Final
Sandra Robinson
 
04 puasa-wajib-dan-sunnah
04 puasa-wajib-dan-sunnah04 puasa-wajib-dan-sunnah
04 puasa-wajib-dan-sunnah
sinaunet
 
Ajith Shetty Resume New1
Ajith Shetty Resume New1Ajith Shetty Resume New1
Ajith Shetty Resume New1
Ajith Shetty
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
Mindsmapped Consulting
 
MARKETING
MARKETINGMARKETING
MARKETING
MADHU SHREE
 
La bocatoma
La bocatomaLa bocatoma
La bocatoma
Jaime Cristian Rodriguez Flores
 
Anomaly ad agency
Anomaly ad agencyAnomaly ad agency
Anomaly ad agency
alexkm123
 
10 qs-an-nahl-114
10 qs-an-nahl-11410 qs-an-nahl-114
10 qs-an-nahl-114
sinaunet
 
Hope For Tomorrow 22 June 2015--final draft
Hope For Tomorrow 22 June 2015--final draftHope For Tomorrow 22 June 2015--final draft
Hope For Tomorrow 22 June 2015--final draft
Sandra Robinson
 
MARKET SHARE OF WOMEN & CHILDREN HEALTH DRINKS
MARKET SHARE OF WOMEN & CHILDREN HEALTH DRINKSMARKET SHARE OF WOMEN & CHILDREN HEALTH DRINKS
MARKET SHARE OF WOMEN & CHILDREN HEALTH DRINKS
MADHU SHREE
 
Greater Curtin Information Memorandum 26 April 2016
Greater Curtin Information Memorandum 26 April 2016Greater Curtin Information Memorandum 26 April 2016
Greater Curtin Information Memorandum 26 April 2016
Tim Urquhart
 
ORL515 Hope for Tomorrow 06-22-15 Final
ORL515 Hope for Tomorrow 06-22-15 FinalORL515 Hope for Tomorrow 06-22-15 Final
ORL515 Hope for Tomorrow 06-22-15 Final
Sandra Robinson
 
04 puasa-wajib-dan-sunnah
04 puasa-wajib-dan-sunnah04 puasa-wajib-dan-sunnah
04 puasa-wajib-dan-sunnah
sinaunet
 
Ajith Shetty Resume New1
Ajith Shetty Resume New1Ajith Shetty Resume New1
Ajith Shetty Resume New1
Ajith Shetty
 
Anomaly ad agency
Anomaly ad agencyAnomaly ad agency
Anomaly ad agency
alexkm123
 
10 qs-an-nahl-114
10 qs-an-nahl-11410 qs-an-nahl-114
10 qs-an-nahl-114
sinaunet
 
Ad

Similar to Java J2EE Interview Question Part 2 (20)

Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
Spring 2
Spring 2Spring 2
Spring 2
Aruvi Thottlan
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Hamid Ghorbani
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
Emprovise
 
Spring from a to Z
Spring from  a to ZSpring from  a to Z
Spring from a to Z
sang nguyen
 
Java spring ppt
Java spring pptJava spring ppt
Java spring ppt
natashasweety7
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
ThirupathiReddy Vajjala
 
141060753008 3715301
141060753008 3715301141060753008 3715301
141060753008 3715301
ITM Universe - Vadodara
 
Spring (1)
Spring (1)Spring (1)
Spring (1)
Aneega
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
NourhanTarek23
 
Struts & spring framework issues
Struts & spring framework issuesStruts & spring framework issues
Struts & spring framework issues
Prashant Seth
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.
suranisaunak
 
Spring framework-tutorial
Spring framework-tutorialSpring framework-tutorial
Spring framework-tutorial
vinayiqbusiness
 
Module 5.ppt.............................
Module 5.ppt.............................Module 5.ppt.............................
Module 5.ppt.............................
Betty333100
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
nomykk
 
Spring survey
Spring surveySpring survey
Spring survey
Chris Roeder
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
Mukesh Kumar
 
Signal Framework
Signal FrameworkSignal Framework
Signal Framework
Aurora Softworks
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
Emprovise
 
Spring from a to Z
Spring from  a to ZSpring from  a to Z
Spring from a to Z
sang nguyen
 
Spring (1)
Spring (1)Spring (1)
Spring (1)
Aneega
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
NourhanTarek23
 
Struts & spring framework issues
Struts & spring framework issuesStruts & spring framework issues
Struts & spring framework issues
Prashant Seth
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.
suranisaunak
 
Spring framework-tutorial
Spring framework-tutorialSpring framework-tutorial
Spring framework-tutorial
vinayiqbusiness
 
Module 5.ppt.............................
Module 5.ppt.............................Module 5.ppt.............................
Module 5.ppt.............................
Betty333100
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
nomykk
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
Mukesh Kumar
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
Ad

Recently uploaded (20)

Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdfProtect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
株式会社クライム
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
Tools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google CertificateTools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google Certificate
VICTOR MAESTRE RAMIREZ
 
Time Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project TechniquesTime Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project Techniques
Livetecs LLC
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
How to avoid IT Asset Management mistakes during implementation_PDF.pdf
How to avoid IT Asset Management mistakes during implementation_PDF.pdfHow to avoid IT Asset Management mistakes during implementation_PDF.pdf
How to avoid IT Asset Management mistakes during implementation_PDF.pdf
victordsane
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?
Amara Nielson
 
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdfProtect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
株式会社クライム
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
Tools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google CertificateTools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google Certificate
VICTOR MAESTRE RAMIREZ
 
Time Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project TechniquesTime Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project Techniques
Livetecs LLC
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
How to avoid IT Asset Management mistakes during implementation_PDF.pdf
How to avoid IT Asset Management mistakes during implementation_PDF.pdfHow to avoid IT Asset Management mistakes during implementation_PDF.pdf
How to avoid IT Asset Management mistakes during implementation_PDF.pdf
victordsane
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?AI in Business Software: Smarter Systems or Hidden Risks?
AI in Business Software: Smarter Systems or Hidden Risks?
Amara Nielson
 

Java J2EE Interview Question Part 2

  • 1. JAVA Interview Questions Part-2 JAVA J2EE Training
  • 2. 51. What are considered as a web component? Java Servlet and Java Server Pages technology components are web components. Servlets are Java programming language that dynamically receive requests and make responses. JSP pages execute as servlets but allow a more natural approach to creating static content. 52. Define Hash table? Hash Table is just like Hash Map or Collection having unique key value pairs. Hash table is a collection of Synchronized object. It does not allow duplicate values but it allows null values. 53. What is Hibernate? Hibernate is a open source object-relational mapping and query service. In hibernate we can write HQL instead of SQL which save developers to spend more time on writing the native SQL. Hibernate has more powerful association, inheritance, polymorphism, composition, and collections. It is a beautiful approach for persisting into database using the java objects. Hibernate also allows you to express queries using java-based criteria.
  • 3. 54. What is ORM? ORM stands for Object-Relational mapping. The objects in a Java class which is mapped in to the tables of a relational database using the metadata that describes the mapping between the objects and the database. It works by transforming the data from one representation to another. 55. Difference between Proxy and Adapter? Adapter object has a different input than the real subject whereas Proxy object has the same input as the real subject. Proxy object is such that it should be placed as it is in place of the real subject. 56. What is MVC? Model-View-Controller is a design pattern wherein Model holds the business logic , Controller controls the flow and View takes care of the presentation part of web application.
  • 4. 57. What is dependency injection or IOC? It's a mechanism of passing object creation to an external component wherein dependent objects are identified and created using configuration. 58. What is bean auto wiring? The Spring container is able to auto wire 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 without using <constructor-arg> and <property> element. 59. What are the different types of IOC (dependency injection)? Constructor Injection (e.g. Pico container, Spring etc): Dependencies are provided as constructor parameters. Setter Injection (e.g. Spring): Dependencies are assigned through JavaBeans properties (ex: setter methods). Interface Injection (e.g. Avalon): Injection is done through an interface. Note: Spring supports only Constructor and Setter Injection
  • 5. 60. What are the advantages of Spring framework? The advantages of Spring are as follows: Spring has layered architecture. Use what you need and leave you don't need now. Spring Enables POJO Programming. There is no behind the scene magic here. POJO programming enables continuous integration and testability. Dependency Injection and Inversion of Control Simplifies JDBC Open source and no vendor lock-in. 61. What are the common implementations of the Application Context? The three commonly used implementation of 'Application Context' are, ClassPathXmlApplicationContext : It Loads context definition from an XML file located in the classpath, treating context definitions as classpath resources. The application context is loaded from the application's classpath by using the code. ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml"); FileSystemXmlApplicationContext : It loads context definition from an XML file in the filesystem. The application context is loaded from the file system by using the code. ApplicationContext context = new FileSystemXmlApplicationContext("bean.xml"); XmlWebApplicationContext : It loads context definition from an XML file contained within a web application.
  • 6. 62. 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. 63. 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. 64. What are the ways to access Hibernate using Spring? There are two approaches to Spring’s Hibernate integration: Inversion of Control with a HibernateTemplate and Callback Extending HibernateDaoSupport and Applying an AOP Interceptor.
  • 7. 65. How the AOP used in Spring? AOP is used in the Spring Framework: To provide declarative enterprise services, especially as a replacement for EJB declarative services. The most important such service is declarative transaction management, which builds on the Spring Framework's transaction abstraction. To allow users to implement custom aspects, complementing their use of OOP with AOP. 66. What is Session Tracking? Session simply means a particular interval of time. Session Tracking is a way to maintain state of an user. Http protocol is a stateless protocol. Each time user requests to the server, server treats the request as the new request. So we need to maintain the state of a user to recognize to particular user. 67. How is a typical spring implementation look like? For a typical Spring Application we need the following files: An interface that defines the functions. An Implementation that contains properties, its setter and getter methods, functions etc., Spring AOP (Aspect Oriented Programming) A XML file called spring configuration file. Client program that uses the function.
  • 8. 68. What is Java Server Faces (JSF) - spring integration mechanism? Spring provides a custom JavaServer Faces VariableResolver implementation that extends the standard JavaServer Faces managed beans mechanism. When asked to resolve a variable name, the following algorithm is performed. 69. 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. 70. How to integrate your Struts application with spring? To integrate your Struts application with spring, we have two options: Configure spring to manage your Actions as beans, using the ContextLoaderPlugin, and set their dependencies in a spring context file. Subclass Spring's ActionSupport classes and grab your Spring-managed beans explicitly using a getWebApplicationContext() method.
  • 9. 71. How to integrate spring and Hibernate? Spring and Hibernate can integrate using spring’s SessionFactory called LocalSessionFactory. The integration process is of 3 steps. Configure Hibernate mappings. Configure Hibernate properties. Wire dependant object to SessionFactory. 72. What are the ways to access Hibernate using Spring? There are two ways to access Hibernate from Spring: Through Hibernate Template. Subclassing HibernateDaoSupport Extending HibernateDaoSupport and Applying an AOP Interceptor 73. Why most users of the Spring Framework choose declarative transaction management? Most users of the Spring Framework choose declarative transaction management because it is the option with the least impact on application code, and hence is most consistent with the ideals of a non-invasive lightweight container.
  • 10. 74. When to use programmatic and declarative transaction management? Programmatic transaction management is usually a good idea only if you have a small number of transactional operations. On the other hand, if your application has numerous transactional operations, declarative transaction management is usually worthwhile. It keeps transaction management out of business logic, and is not difficult to configure. 75. Explain about the Spring DAO support? The Data Access Object (DAO) support in Spring is aimed at making it easy to work with data access technologies like JDBC, Hibernate or JDO in a consistent way. This allows one to switch between the persistence technologies fairly easily and it also allows one to code without worrying about catching exceptions that are specific to each technology. 76.What are the exceptions thrown by the Spring DAO classes? Spring DAO classes throw exceptions which are subclasses of DataAccessException(org.springframework.dao.DataAccessException).Spring provides a convenient translation from technology-specific exceptions like SQLException to its own exception class hierarchy with the DataAccessException as the root exception. These exceptions wrap the original exception.
  • 11. 77. What is SQLExceptionTranslator? SQLExceptionTranslator, is an interface to be implemented by classes that can translate between SQLExceptions and Spring's own data-access-strategy-agnostic org.springframework.dao.DataAccessException. 78. What is Spring's JdbcTemplate ? Spring's JdbcTemplate is central class to interact with a database through JDBC. JdbcTemplate provides many convenience methods for doing things such as converting database data into primitives or objects, executing prepared and callable statements, and providing custom database error handling. JdbcTemplate template = new JdbcTemplate(myDataSource); 79. What is PreparedStatementCreator ? PreparedStatementCreator: Is one of the most commonly used interfaces for writing data to database. Has one method – createPreparedStatement(Connection) Responsible for creating a PreparedStatement. Does not need to handle SQLExceptions.
  • 12. 80. What is Application Context? A bean factory is fine to simple applications, but to take advantage of the full power of the Spring framework, you may want to move up to Springs more advanced container, the application context. On the surface, an application context is same as a bean factory.Both load bean definitions, wire beans together, and dispense beans upon request. But it also provides: * A means for resolving text messages, including support for internationalization. * A generic way to load file resources. * Events to beans that are registered as listeners. 81. What are the types of Dependency Injection Spring supports? Setter Injection: Setter-based DI is realized by calling setter methods on your beans after invoking a no-argument constructor or no-argument static factory method to instantiate your bean. Constructor Injection: Constructor-based DI is realized by invoking a constructor with a number of arguments, each representing a collaborator.
  • 13. 82. What are the exceptions thrown by the Spring DAO classes ? Spring DAO classes throw exceptions which are subclasses of DataAccessException(org.springframework.dao.DataAccessException).Spring provides a convenient translation from technology-specific exceptions like SQLException to its own exception class hierarchy with the DataAccessException as the root exception. These exceptions wrap the original exception. 83. What is Spring's JdbcTemplate ? Spring's JdbcTemplate is central class to interact with a database through JDBC. JdbcTemplate provides many convenience methods for doing things such as converting database data into primitives or objects, executing prepared and callable statements, and providing custom database error handling. JdbcTemplate template = new JdbcTemplate (myDataSource); 84. Explain the three different methods which are provided by the Namespace Handler interface? The three different methods which are provided by the name space handler interface are: 1) Init() is used to allow initialization for name space handler. 2) BeanDefinition parse is used when a Spring encounters a top level element. 3) BeanDefinitionHandler is used when spring encounters an attribute.
  • 14. 85. Which of the beans available in EJB 3 are only called by clients ? Session and Singleton (EJB 3.1) beans are the ones who encapsulate the business logic which is why it is the only bean which is called by clients. Other beans like MDB and Entity beans are called by session and singleton beans to complete the business requirement. 86. Why is it so to make the session beans into two parts one with interface and the other as implementation to the interface? Or why session beans should be used through business interface? (EJB 3.0 Specific). This approach promotes loose coupling since implementation classes can easily be swapped out without a lot of code changes. But in recent EJB 3.1 specification you don't need to implement a business interface for faster development. 87. What is business interface? An interface through which a client invokes the bean is called a business interface. There are three types of business interfaces available in EJB 3 : Local, Remote and WebService
  • 15. 88. Can we have instance fields in Stateless session bean? Yes. A stateless session bean can have instance field, BUT not for storing state information as opposed to Stateful beans. There may be a need of storing certain shareable resources like data source, JMS source etc, which will be used in the exposed method. So it is perfectly safe to have instance fields in the Stateless session beans. 89. Can you inject Stateful beans into stateless session bean or Servlet? Yes!!. Nobody stops you to inject Stateful beans into stateless session bean or a Servlet. Let’s take a Servlet and inject (definitely as a field in Servlet) a Stateful bean; What happens? Container creates a single instance of a Servlet, so the instance field of Servlet ( which is a Stateful Bean ) injected , is shared among clients.It will lead to drastic data inconsistency ( stored in Stateful bean ) being shared by clients. And this is no different for a Stateful bean injected into stateless bean. So you must AVOID injecting into stateless beans and Servlets. Please don't ask how do you access or make use of Stateful bean in Stateless or Servlet.The answer is JNDI inside the methods of Stateless and doGet() or doPost() of Servlet.
  • 16. 90. What are Pull-MVC and push-MVC based architecture ? Whicharchitecture does Struts2 follow? Pull-MVC and Push-MVC are better understood with how the view layer is getting data i.e. Model to render. In case of Push-MVC the data( Model) is constructed and given to the view layer by the Controllers by putting it in the scoped variables like request or session. Typical example is Spring MVC and Struts1. Pull-MVC on the other hand puts the model data typically constructed in Controllers are kept in a common place i.e. in actions, which then gets rendered by view layer. Struts2 is a Pull-MVC based architecture, in which all data is stored in Value Stack and retrieved by view layer for rendering. 91. Are Interceptors in Struts2 thread safe? No, Unlike Struts2 action, Interceptors are shared between requests, so thread issues will come if not taken care of
  • 17. 92. Are Interceptors and Filters different? , If yes then how? Apart from the fact that both Interceptors and filters are based on intercepting filter,there are few differences when it comes to Struts2. Filters: (1)Based on Servlet Specification (2)Executes on the pattern matches on the request.(3) Not configurable method calls Interceptors: (1)Based on Struts2. (2)Executes for all the request qualifies for a front controller( A Servlet filter ).And can be configured to execute additional interceptor for a particular action execution.(3)Methods in the Interceptors can be configured whether to execute or not by means of excludemethods or includeMethods. ( see tutorial on this Controlling Interceptor Behavior) 93. Which class is the front-controller in Struts2? The class "org.apache.struts2.dispatcher.FilterDispatcher " is the front controller in Struts2. In recent time Struts 2.1.3 this class is deprecated and new classes are introduced to do the job. 94. What is the role of Action/ Model? Actions in Struts are POJO, is also considered as a Model. The role of Action are to execute business logic or delegate call to business logic by the means of action methods which is mapped to request and contains business data to be used by the view layer by means of setters and getters inside the Action class and finally helps the framework decide which result to render.
  • 18. 95. What is the relation between ValueStack and OGNL? A ValueStack is a place where all the data related to action and the action itself is stored. OGNL is a mean through which the data in the ValueStack is manipulated. 96. What is the difference between Action and ActionSupport? Action is interface defines some string like SUCCESS,ERROR etc and an execute() method. For convenience Developer implement this interface to have access to String field in action methods. ActionSupport on other hand implements Action and some other interfaces and provides some feature like data validation and localized error messaging when extended in the action classes by developers 97. Who loads the struts.xml file? Which Struts2 API loads the struts.xml file? In Struts2 FilterServlet is the responsible class for loading struts.xml file as we deploy the application on the container. Unlike Servlet (as with Struts1) needs the load-on-startup tag to load the front controller,a filter doesn't need to have load on startup tag to be loaded as the application is deployed. As with servlet specification a filter is loaded/executed as the application starts up.
  • 19. 98. What is JDBC Driver interface? The JDBC Driver interface provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each vendor driver must provide implementations of the java.sql.Connection, Statement, PreparedStatement, CallableStatement, ResultSet and Driver. 99. What is the jspInit() method? The jspInit() method of the javax.servlet.jsp.JspPage interface is similar to the init() method of servlets. This method is invoked by the container only once when a JSP page is initialized. It can be overridden by a page author to initialize resources such as database and network connections, and to allow a JSP page to read persistent configuration data. 100. What is the _jspService() method? The _jspService() method of the javax.servlet.jsp.HttpJspPage interface is invoked every time a new request comes to a JSP page. This method takes the HttpServletRequest and HttpServletResponse objects as its arguments. A page author cannot override this method, as its implementation is provided by the container.
  翻译: