SlideShare a Scribd company logo
1 of 19
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.

More Related Content

What's hot

Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 iimjobs and hirist
 
Java interview questions
Java interview questionsJava interview questions
Java interview questionsSoba Arjun
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Sandeep Rawat
 
Core java interview questions
Core java interview questionsCore java interview questions
Core java interview questionsRohit Singh
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questionsSynergisticMedia
 
Core java lessons
Core java lessonsCore java lessons
Core java lessonsvivek shah
 
9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot missMark Papis
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java ProgrammingMath-Circle
 

What's hot (17)

Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014
 
Core Java
Core JavaCore Java
Core Java
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Java basic
Java basicJava basic
Java basic
 
Core java interview questions
Core java interview questionsCore java interview questions
Core java interview questions
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
 
Technical Interview
Technical InterviewTechnical Interview
Technical Interview
 
Core java lessons
Core java lessonsCore java lessons
Core java lessons
 
Core java
Core javaCore java
Core java
 
JAVA PROGRAMMING
JAVA PROGRAMMING JAVA PROGRAMMING
JAVA PROGRAMMING
 
Design pattern
Design patternDesign pattern
Design pattern
 
Swing api
Swing apiSwing api
Swing api
 
9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
 

Similar to Java J2EE Interview Questions Part 2

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 BasicsEmprovise
 
Spring from a to Z
Spring from  a to ZSpring from  a to Z
Spring from a to Zsang 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.pptxNourhanTarek23
 
Struts & spring framework issues
Struts & spring framework issuesStruts & spring framework issues
Struts & spring framework issuesPrashant 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-tutorialvinayiqbusiness
 
Spring Framework
Spring FrameworkSpring Framework
Spring Frameworknomykk
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworksMukesh 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 ControlArjun Thakur
 

Similar to Java J2EE Interview Questions Part 2 (20)

Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Spring 2
Spring 2Spring 2
Spring 2
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 
Spring from a to Z
Spring from  a to ZSpring from  a to Z
Spring from a to Z
 
Java spring ppt
Java spring pptJava spring ppt
Java spring ppt
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 
141060753008 3715301
141060753008 3715301141060753008 3715301
141060753008 3715301
 
Spring (1)
Spring (1)Spring (1)
Spring (1)
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
 
Struts & spring framework issues
Struts & spring framework issuesStruts & spring framework issues
Struts & spring framework issues
 
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.
 
Spring framework-tutorial
Spring framework-tutorialSpring framework-tutorial
Spring framework-tutorial
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Spring survey
Spring surveySpring survey
Spring survey
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
 
Signal Framework
Signal FrameworkSignal Framework
Signal Framework
 
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
 
Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
 

Recently uploaded

Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 

Recently uploaded (20)

Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 

Java J2EE Interview Questions 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.