SlideShare a Scribd company logo
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Java Market
➢ Java has been rated #1 in TIOBE Popular
programming languages index.
➢ Used by 10 Million developers world wide to
develop applications for the 15 Billion devices
supporting Java.
➢ Used for creating applications for trending
technologies like Big Data to household devices
like Mobiles and DTH boxes, Java is used
everywhere.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Java Job Trends
Below are the number for job postings for Java professionals on various job portals as on 15th March 2017.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Java Job Distribution and Salary Trends
Below are the overall Job Distribution and Average salary trends in the Java Domain as on 15th January 2017.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Agenda For Today
Basic Java Questions
OOPS Questions
Servlets
JDBC
Spring
Hibernate
Basic
Questions
OOPS
Servlets
JDBC Hibernate
Spring
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q1. What is difference between JDK,JRE and JVM?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q1. What is difference between JDK,JRE and JVM?
JDK
JRE
JVM
JVM (Java Virtual Machine) is an abstract machine. It is a
specification that provides runtime environment in which java
bytecode can be executed.
JRE (Java Runtime Environment) is a runtime environment
which implements JVM and provides all class libraries and
other files that JVM uses at runtime.
JDK(Java Development Kit) is the tool necessary to compile,
document and package Java programs. The JDK completely
includes JRE.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q2. What is synchronization?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q2. What is synchronization?
➢ Synchronization is a process which keeps all
concurrent threads in execution to be in sync.
➢ Synchronization avoids memory consistency
errors caused due to inconsistent view of shared
memory.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q3. What are the differences between processes and threads?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q3. What are the differences between processes and threads?
Process Thread
Definition
An executing instance of a program is called a
process.
A thread is a subset of the process.
Communication
Processes must use inter-process communication
to communicate with sibling processes.
Threads can directly communicate with other
threads of its process.
Control
Processes can only exercise control over child
processes.
Threads can exercise considerable control over
threads of the same process.
Changes
Any change in the parent process does not affect
child processes.
Any change in the main thread may affect the
behavior of the other threads of the process.
Memory Run in separate memory spaces. Run in shared memory spaces.
Controlled by Process is controlled by the operating system.
Threads are controlled by programmer in a
program.
Dependence Processes are independent. Threads are dependent.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q4. What are Wrapper classes?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q4. What are Wrapper classes?
Primitive Wrapper Class Constructor Argument
boolean Boolean boolean or String
byte Byte byte or String
char Character char
int Integer int or String
float Float float, double or String
double Double double or String
long Long long or String
short Short short or String
Each of Java's eight primitive data types has a class dedicated to it. These are known as wrapper classes
because they "wrap" the primitive data type into an object of that class
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q5. What purpose does the keywords final, finally, and finalize fulfill?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q5. What purpose does the keywords final, finally, and finalize fulfill?
final finally
➢ Final is used to apply restrictions
on class, method and variable.
➢ Final class can't be inherited, final
method can't be overridden and
final variable value can't be
changed.
➢ Finally is used to place important
code, it will be executed whether
exception is handled or not.
➢ Finalize is used to perform clean
up processing just before object
is garbage collected.
finalize
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q6. What is the difference between StringBuffer and StringBuilder?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
➢ StringBuffer operations are thread-safe and
synchronized where StringBuilder operations are not
thread-safe.
➢ StringBuffer is to be used when multiple threads are
working on same String and StringBuilder in the single
threaded environment.
➢ StringBuilder performance is faster when compared to
StringBuffer because of no overhead of synchronized
Java Interview Questions
Q6. What is the difference between StringBuffer and StringBuilder?
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q7. What are the differences between Heap and Stack Memory?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q7. What are the differences between Heap and Stack Memory?
Stack Heap
Memory
Stack memory is used only by one thread
of execution.
Heap memory is used by all the parts of
the application.
Access
Objects stored in the heap are globally
accessible
Stack memory can’t be accessed by other
threads.
Memory
Management
Follows LIFO manner to free memory.
Memory management is based on
generation associated to each object.
Lifetime
Exists until the end of execution of the
tread.
Heap memory lives from the start till the
end of application execution.
Usage
Stack memory only contains local
primitive variables and reference
variables to objects in heap space.
Whenever an object is created, it’s always
stored in the Heap space
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q8. What is the difference between Arrylist and Vector?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Array List Vector
Array List is not synchronized. Vector is synchronized.
Array List is fast as it’s non-synchronized Vector is slow as it is thread safe.
If an element is inserted into the Array List, it
increases its Array size by 50%.
Vector defaults to doubling size of its array.
Array List does not define the increment size. Vector defines the increment size.
Array List can only use Iterator for traversing an
Array List.
Except Hashtable, Vector is the only other class
which uses both Enumeration and Iterator.
Q8. What is the difference between Arrylist and Vector?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q9. What is the difference between HashMap and HashTable
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q9. What is the difference between HashMap and HashTable
HashMap HashTable
HashMap is non synchronized and are not-
thread safe.
Hashtable is synchronized. It is thread-safe
and can be shared with many threads.
HashMap allows one null key and multiple null
values.
Hashtable doesn't allow any null key or value.
HashMap is fast compared to HashTable Hashtable is slow compared to HashMap
We can make the HashMap as synchronized by
calling Collections.synchronizedMap(hashMap)
Hashtable is internally synchronized and can't
be unsynchronized.
HashMap is traversed by Iterator. Hashtable is traversed by Enumerator and
Iterator.
HashMap inherits AbstractMap class. Hashtable inherits Dictionary class.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Java Interview Questions
Q10. What is the difference between equals() and == operator ?
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Java Interview Questions
Q10. What is the difference between equals() and == operator ?
➢ Equals() method is defined in Object class in Java and
used for checking equality of two objects defined by
business logic.
➢ "==" or equality operator in Java is a binary operator
provided by Java programming language and used to
compare primitives and objects.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q11. What will be the output of this program?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q11. What will be the output of this program?
Output:
11
Java Interview Questions
Basic Questions
OOPS
Questions
Servlets
JDBC Hibernate
Spring
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q12. What is the difference between Abstract classes and Interfaces?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Abstract Class Interfaces
An abstract class can provide complete,
default code and/or just the details that have
to be overridden.
An interface cannot provide any code at
all,just the signature.
In case of abstract class, a class may extend
only one abstract class.
A Class may implement several interfaces.
An abstract class can have non-abstract
methods.
All methods of an Interface are abstract.
An abstract class can have instance variables. An Interface cannot have instance variables.
An abstract class can have any visibility: public,
private, protected.
An Interface visibility must be public (or) none.
An abstract class can contain constructors . An Interface cannot contain constructors .
Abstract classes are fast.
Interfaces are slow as it requires extra
indirection to find corresponding method in
the actual class.
Q12. What is the difference between Abstract classes and Interfaces?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q13. What is Polymorphism?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q13. What is Polymorphism?
Mobile
Camera Remote MP3 Player
➢ Polymorphism is briefly described as “one
interface, many implementations”.
➢ It is a characteristic of being able to assign
a different meaning or usage to something
in different contexts.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q14. What is runtime polymorphism or dynamic method dispatch?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q14. What is runtime polymorphism or dynamic method dispatch?
➢ It is a process in which a call to an overridden method is
resolved at runtime rather than at compile-time.
➢ In this process, an overridden method is called through
the reference variable of a superclass.
➢ The determination of the method to be called is based
on the object being referred to by the reference variable.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q15. What is the difference between method overloading and method overriding?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q15. What is the difference between method overloading and method overriding?
Overloaded Method Overridden Method
Definition
In Method Overloading, Methods of the same
class shares the same name but each method
must have different number of parameters or
parameters having different types and order.
In Method Overriding, sub class have the same
method with same name and exactly the same
number and type of parameters and same return
type as a super class.
Behavior
Method Overloading is to “add” or “extend” more
to method’s behavior.
Method Overriding is to “Change” existing
behavior of method.
Polymorphism It is a compile time polymorphism. It is a run time polymorphism.
Signature The methods must have different signature. The methods must have same signature.
Inheritance
It may or may not need inheritance in Method
Overloading.
It always requires inheritance in Method
Overriding.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q15. What is the difference between Method overloading and Method overriding?
Method overloading Method overriding
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q16. Can you override a private or static method in Java?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q16. Can you override a private or static method in Java?
➢ A private method cannot be overridden since it
is not visible from any other class.
➢ If you create a similar method with same return
type and same method arguments in child class
then it will hide the super class method; this is
known as method hiding.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q17. What is multiple inheritance and does java support?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q17. What is multiple inheritance and does java support?
➢ If a child class inherits the property from multiple
classes is known as multiple inheritance.
➢ The problem with multiple inheritance is that if
multiple parent classes have a same method
name, then at runtime it becomes difficult for the
compiler to decide which method to execute from
the child class
Class A
Class A Class A
Class A
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q18. What will be the output of this program?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q18. What will be the output of this program?
Output:
I am foo in Super
I am foo in Child
I am bar in Child
I am bar in Child
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q19. What will be the output of this program?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q19. What will be the output of this program?
Output:
How are you?
Hello
Hi
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q20. What will be the output of this program?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q20. What will be the output of this program?
Output:
First 2
Third 0
Second 2
Fourth 6
6
Java Interview Questions
Basic Questions
OOPS Questions
Servlets
JDBC Hibernate
Spring
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q21. What is a Servlet?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q21. What is a Servlet?
➢ Java Servlet is server side technologies to extend the capability
of web servers by providing support for dynamic response and
data persistence.
➢ The javax.servlet and javax.servlet.http packages provide
interfaces and classes for writing our own servlets.
➢ All servlets must implement the javax.servlet.Servlet interface,
which defines servlet lifecycle methods.
➢ As most web applications are accessed using HTTP protocol ,we
mostly extend HttpServlet class. Servlet API hierarchy. Servlet
Browser
Internet
Java Web
Server
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q22. What is difference between Get and Post method?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q22. What is difference between Get and Post method?
Java Interview Questions
Get Post
Limited amount of data can be sent
because data is sent in header.
Large amount of data can be sent
because data is sent in body.
Not Secured because data is exposed
in URL bar.
Secured because data is not
exposed in URL bar.
Can be bookmarked Cannot be bookmarked
Idempotent Non-Idempotent
It is more efficient and used than Post It is less efficient and used
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q23. What are different methods of session management in servlets?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q23. What are different methods of session management in servlets?
Java Interview Questions
➢ Session is a conversational state between client and server and it can consists of multiple request and response
between client and server.
➢ Since HTTP and Web Server both are stateless, the only way to maintain a session is when some unique
information about the session (session id) is passed between server and client in every request and response.
Session Management
User
Authentication
HTML Hidden Field Cookies URL Rewriting
Session
Management API
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q24. What is the .Difference between ServletContext vs ServletConfig?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q24. What is the .Difference between ServletContext vs ServletConfig?
Java Interview Questions
ServletConfig ServletContext
Servlet config object represent single servlet
It represent whole web application running on particular
JVM and common for all the servlet
Its like local parameter associated with particular servlet
Its like global parameter associated with whole
application
It’s a name value pair defined inside the servlet section
of web.xml file so it has servlet wide scope
ServletContext has application wide scope so define
outside of servlet tag in web.xml file.
getServletConfig() method is used to get the config
object
getServletContext() method is used to get the context
object.
E.g. Shopping cart of a user is a specific to particular
user so here we can use servlet config
To get the MIME type of a file or application session
related information is stored using servlet context
object.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q25. What is the life-cycle of a servlet?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Java Interview Questions
Q25. What is the life-cycle of a servlet?
There are 5 stages in the lifecycle of a servlet:
➢ Servlet is loaded
➢ servlet is instantiated
➢ servlet is initialized
➢ service the request
➢ servlet is destroyed
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q26. What is Request Dispatcher?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q26. What is Request Dispatcher?
➢ RequestDispatcher interface is used to forward the
request to another resource that can be HTML, JSP
or another servlet in same application.
➢ We can also use this to include the content of
another resource to the response.
➢ There are two methods defined in this interface:
1. void forward()
2. void include()
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q27. How does Cookies work in Servlets?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q27. How does Cookies work in Servlets?
Java Interview Questions
➢ Cookies are text data sent by server to the client and it gets saved at the client local machine.
➢ Servlet API provides cookies support through javax.servlet.http.Cookie class that implements Serializable and
Cloneable interfaces.
➢ HttpServletRequest getCookies() method is provided to get the array of Cookies from request, since there is no
point of adding Cookie to request, there are no methods to set or add cookie to request.
➢ Similarly HttpServletResponse addCookie(Cookie c) method is provided to attach cookie in response header,
there are no getter methods for cookie.
Basic Questions
OOPS Questions
Servlets
JDBC
Hibernate
Spring
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q28. What is JDBC Driver?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q28. What is JDBC Driver?
JDBC Driver is a software component that enables java
application to interact with the database. There are 4
types of JDBC drivers:
➢JDBC-ODBC bridge driver
➢Native-API driver (partially java driver)
➢Network Protocol driver (fully java driver)
➢Thin driver (fully java driver)
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q29. What are the steps to connect to the database in java?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q29. What are the steps to connect to the database in java?
There are 5 steps we need to follow to connect
to a database in Java
➢ Registering the driver class
➢ Creating connection
➢ Creating statement
➢ Executing queries
➢ Closing connection
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q30. What are the different JDBC API components?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Interfaces Classes
Q30. What are the different JDBC API components?
Interfaces
Connection
Statement
Prepared
Statement
ResultSet
ResultSet
MetaData
Database
MetaData
Callable
Statement
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q31. What is a JDBC Connection interface?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q31. What is a JDBC Connection interface?
Java Interview Questions
The Connection interface maintains a session with the database. It can be used for transaction management.
Connection Interface
createStatement()
createStatement(result
SetType,
resultSetConcurrency)
setAutoCommit(
boolean status)
commit() rollback() close()
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q32. What is the difference between execute, executeQuery, executeUpdate?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q32. What is the difference between execute, executeQuery, executeUpdate?
Java Interview Questions
Basic Questions
OOPS Questions
Servlets
JDBC Hibernate
Spring
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q33. What is Spring?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q33. What is Spring?
Java Interview Questions
➢ It is an application framework and inversion of control container for the Java platform.
➢ The framework’s core features can be used by any Java application, but there are extensions for building web
applications on top of the Java EE platform.”
➢ Spring is essentially a lightweight, integrated framework that can be used for developing enterprise applications
in java.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q34. What are the different modules of the Spring framework.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q34. What are the different modules of the Spring framework.
Some of the important Spring Framework modules are:
➢ Spring Context – for dependency injection.
➢ Spring AOP – for aspect oriented programming.
➢ Spring DAO – for database operations using DAO pattern
➢ Spring JDBC – for JDBC and DataSource support.
➢ Spring ORM – for ORM tools support such as Hibernate
➢ Spring Web Module – for creating web applications.
➢ Spring MVC – Model-View-Controller implementation for
creating web applications, web services etc.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q35. List some of the important annotations in annotation-based Spring configuration
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q35. List some of the important annotations in annotation-based Spring configuration
Java Interview Questions
Annotation
@Required
@Autowired
@Qualifier
@Resource
@PostConstruct
@PreDestroy
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q36. What is a Bean in Spring and Explain the different scopes of bean in Spring?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q36. What is a Bean in Spring and Explain the different scopes of bean in Spring?
Java Interview Questions
➢ .A bean is an object that is instantiated, assembled, and managed by a Spring IoC container.
➢ They are managed by the Spring IoC container.
➢ There are 5 scopes of beans in Spring :
Scope
Singleton Prototype Request Session Global-Session
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q37. How is a bean added to a Spring application?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Java Interview Questions
Q37. How is a bean added to a Spring application?
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q38. Explain the role of DispatcherServlet and ContextLoaderListener.
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q38. Explain the role of DispatcherServlet and ContextLoaderListener.
Java Interview Questions
DispatcherServlet
DispatcherServlet is the front controller in the Spring MVC
application as it loads the spring bean configuration file and
initializes all the beans that have been configured.
ContextLoaderListener
ContextLoaderListener, the listener to start up and shut
down the WebApplicationContext in Spring root.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q39. What is the difference between constructor injection and setter injection?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q39. What is the difference between constructor injection and setter injection?
Java Interview Questions
Constructor Injection Setter Injection
No Partial Injection Partial Injection
Desn't override the setter property
Overrides the constructor property if
both are defined.
Creates new instance if any
modification occurs
Doesn't create new instance if you
change the property value
Better for too many properties Better for few properties.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q40. What is autowiring in spring? What are the autowiring modes?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q40. What is autowiring in spring? What are the autowiring modes?
Java Interview Questions
Autowiring enables the programmer to inject the bean automatically. We don't need to write explicit injection logic.
Let's see the code to inject bean using dependency injection.
1. <bean id="emp" class="com.javatpoint.Employee" autowire="byName" />
Mode Description
no This is the default mode, it means autowiring is not enabled.
byName
injects the bean based on the property name. It uses setter
method.
byType
injects the bean based on the property type. It uses setter
method.
constructor It injects the bean using constructor
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q41. How to handle exceptions in Spring MVC Framework?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q41. How to handle exceptions in Spring MVC Framework?
Java Interview Questions
Spring MVC Framework provides following ways to help us
achieving robust exception handling.:
➢ Controller Based – We can define exception handler
methods in our controller classes.
➢ Global Exception Handler – Exception Handling is a cross-
cutting concern and Spring provides .
➢ HandlerExceptionResolver –Any Spring bean declared in
the DispatcherServlet’s application context that
implements HandlerExceptionResolver will be used to
intercept and process any exception raised in the MVC
system and not handled by a Controller.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q42. What are some of the important Spring annotations used?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Java Interview Questions
Q42. What are some of the important Spring annotations used?
@Controller
@RequestMapping @ResponseBody
@PathVariable @Qualifier
@Autowired @Service
@Scope
@Aspect
@Configuration
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q43. How to integrate Spring and Hibernate Frameworks?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q43. How to integrate Spring and Hibernate Frameworks?
Java Interview Questions
➢ We can use Spring ORM module to integrate Spring and
Hibernate frameworks
➢ Spring ORM also provides support for using Spring
declarative transaction management,
Basic Questions
OOPS Questions
Servlets
JDBC
Hibernate
Spring
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q44. What is Hibernate Framework?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q44. What is Hibernate Framework?
Java Interview Questions
➢ Hibernate is java based ORM tool that provides framework for mapping application domain objects to the
relational database tables and vice versa.
➢ Hibernate provides reference implementation of Java Persistence API, that makes it a great choice as ORM tool
with benefits of loose coupling.
➢ Hibernate configurations are flexible and can be done from XML configuration file as well as programmatically.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q45. What are the important benefits of using Hibernate Framework?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q45. What are the important benefits of using Hibernate Framework?
Java Interview Questions
1. Hibernate eliminates all the boiler-plate code.
2. Hibernate framework provides support for XML as well as JPA
annotations.
3. Hibernate provides a powerful query language (HQL) that is
similar to SQL.
4. Hibernate is an open source project from Red Hat Community
and used worldwide.
5. For database vendor specific feature, hibernate is suitable
because we can also execute native sql queries.
6. 7. Hibernate cache helps us in getting better performance.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q46. Explain hibernate architecture?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q46. Explain hibernate architecture?
Java Interview Questions
Hibernate
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q47. What is the difference between get and load method?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q47. What is the difference between get and load method?
Java Interview Questions
get() load()
Returns null if object is not found. Throws ObjectNotFoundException if
object is not found.
get() method always hit the database. load() method doesn't hit the database.
It returns real object not proxy. It returns proxy object.
It should be used if you are not sure
about the existence of instance.
It should be used if you are sure that
instance exists.
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q48. What are the advantages of Hibernate over JDBC?
Java Interview Questions
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA /J2EE SOA CERTIFICATION TRAINING
Q48. What are the advantages of Hibernate over JDBC?
Java Interview Questions
1. Hibernate removes boiler-plate code that comes with JDBC API
2. Hibernate supports inheritance, associations and collections which are not
present with JDBC API.
3. Hibernate implicitly provides transaction management.
4. JDBC API throws SQLException that is a checked exception, so we need to
write a lot of try-catch block code.
5. Hibernate Query Language (HQL) is more object oriented and close to java
programming language. For JDBC, we need to write native sql queries.
6. Hibernate supports caching that is better for performance, JDBC queries
are not cached hence performance is low.
Thank You
Questions/Queries/Feedback

More Related Content

PPTX
laravel.pptx
PDF
Java Training | Java Tutorial for Beginners | Java Programming | Java Certifi...
PPT
JavaScript - An Introduction
PDF
PPTX
Coding standards for java
PPTX
Web development with django - Basics Presentation
PPTX
Introduction à spring boot
PPT
JDBC – Java Database Connectivity
laravel.pptx
Java Training | Java Tutorial for Beginners | Java Programming | Java Certifi...
JavaScript - An Introduction
Coding standards for java
Web development with django - Basics Presentation
Introduction à spring boot
JDBC – Java Database Connectivity

What's hot (20)

PDF
07 java collection
PPTX
SQLite - Overview
PDF
Basics of JavaScript
PDF
Basic Java Programming
PDF
JAVA PPT Part-1 BY ADI.pdf
PPT
JavaScript Tutorial
PDF
Introduction to Django REST Framework, an easy way to build REST framework in...
PDF
Django Tutorial | Django Web Development With Python | Django Training and Ce...
PPSX
Oracle Advanced SQL
PPTX
Java Spring Framework
PPT
Introduction to Javascript
PPT
PHP - Introduction to Object Oriented Programming with PHP
PDF
Java Classes | Java Tutorial for Beginners | Java Classes and Objects | Java ...
PDF
Introduction to java (revised)
PPSX
Introduction to java
PDF
A Basic Django Introduction
PPTX
Soap vs rest
PDF
Quick flask an intro to flask
PPSX
Arrays in Java
PPT
Jsp ppt
07 java collection
SQLite - Overview
Basics of JavaScript
Basic Java Programming
JAVA PPT Part-1 BY ADI.pdf
JavaScript Tutorial
Introduction to Django REST Framework, an easy way to build REST framework in...
Django Tutorial | Django Web Development With Python | Django Training and Ce...
Oracle Advanced SQL
Java Spring Framework
Introduction to Javascript
PHP - Introduction to Object Oriented Programming with PHP
Java Classes | Java Tutorial for Beginners | Java Classes and Objects | Java ...
Introduction to java (revised)
Introduction to java
A Basic Django Introduction
Soap vs rest
Quick flask an intro to flask
Arrays in Java
Jsp ppt
Ad

Similar to Java Interview Questions and Answers | Spring and Hibernate Interview Questions | Java Tutorial | Edureka (20)

PDF
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
PDF
50+ java interview questions
PPT
Java interview-questions-and-answers
PDF
Java Interview Questions by NageswaraRao
PDF
Javainterviewquestions 110607071413-phpapp02
PDF
Javainterviewquestions 110607071413-phpapp02
PPTX
Java J2EE Interview Questions Part-1
PPTX
Java J2EE Interview Questions Part-1
DOCX
Java interview questions
PDF
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
PDF
Java interview question
PDF
Java Interview Questions
PDF
JAVA INTERVIEW QUESTIONS.pdf java developer engineer
PDF
JAVA TECHNICAL INTERVIEW.pdf java developer engineer
PDF
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
PDF
java04
DOCX
Basic java important interview questions and answers to secure a job
PPTX
Java interview questions 2
PDF
Java Interview Questions PDF By ScholarHat
DOC
Core java interview questions1
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
50+ java interview questions
Java interview-questions-and-answers
Java Interview Questions by NageswaraRao
Javainterviewquestions 110607071413-phpapp02
Javainterviewquestions 110607071413-phpapp02
Java J2EE Interview Questions Part-1
Java J2EE Interview Questions Part-1
Java interview questions
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java interview question
Java Interview Questions
JAVA INTERVIEW QUESTIONS.pdf java developer engineer
JAVA TECHNICAL INTERVIEW.pdf java developer engineer
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
java04
Basic java important interview questions and answers to secure a job
Java interview questions 2
Java Interview Questions PDF By ScholarHat
Core java interview questions1
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
PDF
Top 5 Trending Business Intelligence Tools | Edureka
PDF
Tableau Tutorial for Data Science | Edureka
PDF
Python Programming Tutorial | Edureka
PDF
Top 5 PMP Certifications | Edureka
PDF
Top Maven Interview Questions in 2020 | Edureka
PDF
Linux Mint Tutorial | Edureka
PDF
How to Deploy Java Web App in AWS| Edureka
PDF
Importance of Digital Marketing | Edureka
PDF
RPA in 2020 | Edureka
PDF
Email Notifications in Jenkins | Edureka
PDF
EA Algorithm in Machine Learning | Edureka
PDF
Cognitive AI Tutorial | Edureka
PDF
AWS Cloud Practitioner Tutorial | Edureka
PDF
Blue Prism Top Interview Questions | Edureka
PDF
Big Data on AWS Tutorial | Edureka
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
PDF
Kubernetes Installation on Ubuntu | Edureka
PDF
Introduction to DevOps | Edureka
What to learn during the 21 days Lockdown | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Tableau Tutorial for Data Science | Edureka
Python Programming Tutorial | Edureka
Top 5 PMP Certifications | Edureka
Top Maven Interview Questions in 2020 | Edureka
Linux Mint Tutorial | Edureka
How to Deploy Java Web App in AWS| Edureka
Importance of Digital Marketing | Edureka
RPA in 2020 | Edureka
Email Notifications in Jenkins | Edureka
EA Algorithm in Machine Learning | Edureka
Cognitive AI Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Blue Prism Top Interview Questions | Edureka
Big Data on AWS Tutorial | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Kubernetes Installation on Ubuntu | Edureka
Introduction to DevOps | Edureka

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
Teaching material agriculture food technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Cloud computing and distributed systems.
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Encapsulation theory and applications.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
A Presentation on Artificial Intelligence
PPTX
Spectroscopy.pptx food analysis technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Network Security Unit 5.pdf for BCA BBA.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Teaching material agriculture food technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Cloud computing and distributed systems.
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
cuic standard and advanced reporting.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Encapsulation theory and applications.pdf
sap open course for s4hana steps from ECC to s4
gpt5_lecture_notes_comprehensive_20250812015547.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
20250228 LYD VKU AI Blended-Learning.pptx
A Presentation on Artificial Intelligence
Spectroscopy.pptx food analysis technology
Advanced methodologies resolving dimensionality complications for autism neur...
Network Security Unit 5.pdf for BCA BBA.

Java Interview Questions and Answers | Spring and Hibernate Interview Questions | Java Tutorial | Edureka