SlideShare a Scribd company logo
JAVA INTERVIEW QUESTIONS FOR FRESHERS
Why Java is platform independent?
Java is called platform independent because of its byte codes which can run on any
system irrespective of its underlying operating system.
Why Java is not 100%Object-oriented?
Java is not 100% Object-oriented becauseit makes use of eight primitive data
types such as boolean, byte, char, int, float, double, long, short which are not
objects.
What are constructors in Java?
In Java, constructorrefers to a block of codewhich is used to initialize an object. It
must have the same name as that of the class. Also, it has no return type and it is
automatically called when an object is created.
There are two types of constructors:
1. Default Constructor: In Java, a default constructoris the one which does
not take any inputs. In other words, default constructors are the no argument
constructors which will be created by default in case you no other
constructoris defined by the user. Its main purposeis to initialize the
instance variables with the default values. Also, it is majorly used for object
creation.
2. ParameterizedConstructor: The parameterized constructorin Java, is the
constructorwhich is capable of initializing the instance variables with the
provided values. In other words, the constructors which take the arguments
are called parameterized constructors.
Why pointers are not used in Java?
Java doesn’tuse pointers because they are unsafe and increases the complexity of
the program. Since, Java is known for its simplicity of code, adding the conceptof
pointers will be contradicting. Moreover, since JVM is responsible for implicit
memory allocation, thus in order to avoid direct access to memory by the
user, pointers are discouraged in Java.
What is the difference between an array and an array list?
Array ArrayList
Cannot contain values of different
data types
Can contain values of different data types.
Size must be defined at the time of
declaration
Size can be dynamically changed
Need to specify the index in order to
add data
No need to specify the index
Arrays are not type parameterized Arraylists are type
Arrays can contain primitive data
types as well as objects
Arraylists can contain only objects, no
primitive data types are allowed
What is a Map in Java?
In Java, Map is an interface of Util package which maps unique keys to values.
The Map interface is not a subset of the main Collection interface and thus it
behaves little different from the other collection types. Below are a few of the
characteristics of Map interface:
1. Map doesn’tcontain duplicate keys.
2. Each key can map at max one value.
What is a classloaderin Java?
The Java ClassLoader is a subsetof JVM (Java Virtual Machine) that is
responsible for loading the class files. Whenever a Java program is executed it is
first loaded by the classloader. Java provides three built-in classloaders:
1. Bootstrap ClassLoader
2. Extension ClassLoader
3. System/Application ClassLoader
What are access modifiers in Java?
In Java, access modifiers are special keywords which are used to restrict the access
of a class, constructor, data member and method in another class. Java supports
four types of access modifiers:
1. Default
2. Private
3. Protected
4. Public
Define a Java Class.
A class in Java is a blueprint which includes all your data. A class contains fields
(variables) and methods to describe the behavior of an object. Let’s have a look at
the syntax of a class.
1
2
3
class Abc {
member variables // class body
methods}
What is an objectin Java and how is it created?
An object is a real-world entity that has a state and behavior. An object has three
characteristics:
1. State
2. Behavior
3. Identity
An object is created using the ‘new’ keyword. For example:
ClassName obj= new ClassName();
OOPS Java Interview Questions
What is run time polymorphism and compile time polymorphism?
Compile time polymorphism is method overloading whereas Runtime time
polymorphism is done using inheritance and interface.
In Java, runtime polymorphism or dynamic method dispatch 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. Let’s take a look at the example below to understand it better.
What is abstractionin Java?
Abstraction refers to the quality of dealing with ideas rather than events. It
basically deals with hiding the details and showing the essential things to the user.
Thus you can say that abstraction in Java is the process ofhiding the
implementation details from the user and revealing only the functionality to them.
Abstraction can be achieved in two ways:
1. Abstract Classes (0-100% of abstraction can be achieved)
2. Interfaces (100% of abstraction can be achieved)
What do you mean by an interface in Java?
An interface in Java is a blueprint of a class or you can say it is a collection of
abstract methods and static constants. In an interface, each method is public and
abstract but it does not contain any constructor. Thus, interface basically is a group
of related methods with empty bodies.
Example:
public interface Animal {
public void eat();
public void sleep();
public void run();
}
What is inheritance in Java?
Inheritance in Java is the conceptwhere the properties of one class can be inherited
by the other. It helps to reuse the codeand establish a relationship between
different classes. Inheritance is performed between two types of classes:
1. Parent class (Super or Base class)
2. Child class (Subclass or Derived class)
A class which inherits the properties is known as Child Class whereas a class
whose properties are inherited is known as Parent class.
What are the different types of inheritance in Java?
Java supports four types of inheritance which are:
1. Single Inheritance: In single inheritance, one class inherits the properties of
another i.e there will be only one parent as well as one child class.
2. Multilevel Inheritance: When a class is derived from a class which is also
derived from another class, i.e. a class having more than one parent class but
at different levels, such type of inheritance is called Multilevel Inheritance.
3. HierarchicalInheritance: When a class has more than one child classes
(subclasses)or in other words, more than one child classes have the same
parent class, then such kind of inheritance is known as hierarchical.
4. Hybrid Inheritance: Hybrid inheritance is a combination of two or more
types of inheritance.
What is method overloading and method overriding?
Method Overloading :
 In Method Overloading, Methods of the same class shares the same name
but each method must have a different number of parameters or parameters
having different types and order.
 Method Overloading is to “add”or “extend” more to the method’s behavior.
 It is a compile-time polymorphism.
 The methods must have a different signature.
 It may or may not need inheritance in Method Overloading.
Method Overriding:
 In Method Overriding, the subclass has the same method with the same
name and exactly the same number and type of parameters and same return
type as a superclass.
 Method Overriding is to “Change” existing behavior of the method.
 It is a run time polymorphism.
 The methods must have the same signature.
 It always requires inheritance in Method Overriding.
What is multiple inheritance? Is it supported by Java?
If a child class inherits the property from multiple classes is known as multiple
inheritance. Java does not allow to extend multiple classes.
The problem with multiple inheritance is that if multiple parent classes have the
same method name, then at runtime it becomes difficult for the compiler to decide
which method to execute from the child class.
Therefore, Java doesn’tsupportmultiple inheritance. The problem is commonly
referred to as Diamond Problem.
In case you are facing any challenges with these java interview questions, please
comment on your problems in the section below.
What is encapsulationin Java?
Encapsulation is a mechanism where you bind your data(variables) and
code(methods)together as a single unit. Here, the data is hidden from the outer
world and can be accessed only via current class methods. This helps in protecting
the data from any unnecessary modification. We can achieve encapsulation in Java
by:
 Declaring the variables of a class as private.
 Providing public setter and getter methods to modify and view the values of
the variables.
Servlets – Java Interview Questions
What is RequestDispatcher?
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()
What is the life-cycle of a servlet?
There are 5 stages in the lifecycle of a servlet:
1. Servlet is loaded
2. Servlet is instantiated
3. Servlet is initialized
4. Service the request
5. Servlet is destroyed
. What are the different methods of sessionmanagementin servlets?
Some of the common ways of session management in servlets are:
1. User Authentication
2. HTML Hidden Field
3. Cookies
4. URL Rewriting
5. Session Management API
JDBC – Java Interview Questions
What is JDBC Driver?
JDBC Driver is a software componentthat enables java application to interact with
the database. There are 4 types of JDBC drivers:
1. JDBC-ODBC bridge driver
2. Native-API driver (partially java driver)
3. Network Protocoldriver (fully java driver)
4. Thin driver (fully java driver)
What are the JDBC API components?
The java.sql package contains interfaces and classes for JDBC API.
Interfaces:
 Connection
 Statement
 PreparedStatement
 ResultSet
 ResultSetMetaData
 DatabaseMetaData
 CallableStatement etc.
Classes:
 DriverManager
 Blob
 Clob
 Types
 SQLException etc.
What is the role of JDBC DriverManagerclass?
The DriverManager class manages the registered drivers. It can be used to register
and unregister drivers. It provides factory method that returns the instance of
Connection.
What is JDBC Connectioninterface?
The Connection interface maintains a sessionwith the database. It can be used for
transaction management. It provides factory methods that returns the instance of
Statement, PreparedStatement, CallableStatement and DatabaseMetaData.
What are the steps to connectto a database in java?
 Registering the driver class
 Creating connection
 Creating statement
 Executing queries
 Closing connection
What is JDBC DatabaseMetaDatainterface?
The DatabaseMetaData interface returns the information of the database such as
username, driver name, driver version, number of tables, number of views etc.
Spring Framework – Java Interview Questions
List some of the important annotations in annotation-basedSpring
configuration.
The important annotations are:
 @Required
 @Autowired
 @Qualifier
 @Resource
 @PostConstruct
 @PreDestroy
What is autowiring in Spring? What are the autowiring modes?
Autowiring enables the programmer to inject the bean automatically. We don’t
need to write explicit injection logic.
The autowiring modes are given below:
No, by name, by type, constructor
Name the types of transactionmanagement that Spring supports.
Programmatic transaction management
Declarative transaction management
JSP – Java Interview Questions
What are the different tags provided in JSTL?
There are 5 type of JSTL tags.
1. core tags
2. sqltags
3. xml tags
4. internationalization tags
5. functions tags
How to disable sessionin JSP?
1. <%@ page session=“false” %>
Exception and Thread Java Interview Questions
How can you handle Java exceptions?
There are five keywords used to handle exceptions in Java:
1. try
2. catch
3. finally
4. throw
5. throws
What are the important methods of Java Exception Class?
String getMessage()
String getLocalizedMessage()
Synchronized Throwable getCause()
String toString()
void printStackTrace()
What is OutOfMemoryError in Java?
OutOfMemoryError is the subclass of java.lang.Error which generally occurs when
our JVM runs out of memory.
What are the two ways to create a thread?
In Java, threads can be created in the following two ways:-
 By implementing the Runnable interface.
 By extending the Thread

More Related Content

DOCX
SQL Interview Questions For Experienced
DOCX
Python Interview Questions For Experienced
PPTX
Actors model in gpars
PPT
DOC
My c++
PPT
Java Notes
PPTX
Classes objects in java
PPTX
Java interview questions 1
SQL Interview Questions For Experienced
Python Interview Questions For Experienced
Actors model in gpars
My c++
Java Notes
Classes objects in java
Java interview questions 1

What's hot (20)

PPTX
Basics of Java
PDF
Java basic concept
PPTX
OCA Java SE 8 Exam Chapter 2 Operators & Statements
PDF
Chapter 01 Introduction to Java by Tushar B Kute
PPTX
The Go Programing Language 1
PDF
DBMS and Rdbms fundamental concepts
PDF
Generics
PPT
Ap Power Point Chpt7
PPT
Unit 1 Java
PDF
Lecture 8 Library classes
ODP
OOP java
PDF
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
PDF
Wrapper classes
PPTX
Object oriented programming in java
PPTX
OCA Java SE 8 Exam Chapter 3 Core Java APIs
PPTX
Structure of java program diff c- cpp and java
PDF
Java essentials for hadoop
PPTX
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
PDF
C++ Object oriented concepts & programming
DOCX
Java se 8 fundamentals
Basics of Java
Java basic concept
OCA Java SE 8 Exam Chapter 2 Operators & Statements
Chapter 01 Introduction to Java by Tushar B Kute
The Go Programing Language 1
DBMS and Rdbms fundamental concepts
Generics
Ap Power Point Chpt7
Unit 1 Java
Lecture 8 Library classes
OOP java
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Wrapper classes
Object oriented programming in java
OCA Java SE 8 Exam Chapter 3 Core Java APIs
Structure of java program diff c- cpp and java
Java essentials for hadoop
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
C++ Object oriented concepts & programming
Java se 8 fundamentals
Ad

Similar to Java Interview Questions For Freshers (20)

PDF
Java Interview Questions
PPTX
Presentation2.ppt java basic core ppt .
PPTX
chapter 5 concepts of object oriented programming
DOCX
PPT
Java_notes.ppt
PPTX
PPT Lecture-1.4.pptx
PDF
Core Java Interview Questions PDF By ScholarHat
PPTX
Nitish Chaulagai Java1.pptx
PPTX
Automation Testing - Part 2 (Things to know in JAVA) - SLT
PPTX
Automation Testing - Part 2 (Things to know in JAVA) - SLT
PDF
Android interview questions
PDF
Android interview questions
PDF
JAVA Class Presentation.pdf Vsjsjsnheheh
PPTX
PDF
JAVA INTERVIEW QUESTIONS.pdf java developer engineer
PDF
JAVA TECHNICAL INTERVIEW.pdf java developer engineer
PPTX
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
PPTX
Android Training (Java Review)
PPTX
OOP in Java Presentation.pptx
Java Interview Questions
Presentation2.ppt java basic core ppt .
chapter 5 concepts of object oriented programming
Java_notes.ppt
PPT Lecture-1.4.pptx
Core Java Interview Questions PDF By ScholarHat
Nitish Chaulagai Java1.pptx
Automation Testing - Part 2 (Things to know in JAVA) - SLT
Automation Testing - Part 2 (Things to know in JAVA) - SLT
Android interview questions
Android interview questions
JAVA Class Presentation.pdf Vsjsjsnheheh
JAVA INTERVIEW QUESTIONS.pdf java developer engineer
JAVA TECHNICAL INTERVIEW.pdf java developer engineer
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Android Training (Java Review)
OOP in Java Presentation.pptx
Ad

More from zynofustechnology (13)

DOCX
JAVA QUESTIONS -6
DOCX
JAVA QUESTIONS FOR INTERVIEW-3
PDF
PYTHON INTERVIEW QUESTIONS-4
PDF
PYTHON INTERVIEW QUESTIONS-2
PDF
JAVA INTERVIEW QUESTIONS -3
PDF
Java Interview Questions-5
DOCX
Java Interview Questions - 1
DOCX
Software Testing Interview Questions For Experienced
DOCX
Python Interview Questions For Freshers
DOCX
HR interview questions
DOCX
Digital marketing questions -3
DOCX
Digital marketing questions -2
DOCX
Digital marketing questions 1
JAVA QUESTIONS -6
JAVA QUESTIONS FOR INTERVIEW-3
PYTHON INTERVIEW QUESTIONS-4
PYTHON INTERVIEW QUESTIONS-2
JAVA INTERVIEW QUESTIONS -3
Java Interview Questions-5
Java Interview Questions - 1
Software Testing Interview Questions For Experienced
Python Interview Questions For Freshers
HR interview questions
Digital marketing questions -3
Digital marketing questions -2
Digital marketing questions 1

Recently uploaded (20)

PDF
composite construction of structures.pdf
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Geodesy 1.pptx...............................................
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Construction Project Organization Group 2.pptx
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPT
Project quality management in manufacturing
composite construction of structures.pdf
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
CH1 Production IntroductoryConcepts.pptx
III.4.1.2_The_Space_Environment.p pdffdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Geodesy 1.pptx...............................................
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
CYBER-CRIMES AND SECURITY A guide to understanding
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Embodied AI: Ushering in the Next Era of Intelligent Systems
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Operating System & Kernel Study Guide-1 - converted.pdf
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Foundation to blockchain - A guide to Blockchain Tech
Construction Project Organization Group 2.pptx
Fundamentals of safety and accident prevention -final (1).pptx
Project quality management in manufacturing

Java Interview Questions For Freshers

  • 1. JAVA INTERVIEW QUESTIONS FOR FRESHERS Why Java is platform independent? Java is called platform independent because of its byte codes which can run on any system irrespective of its underlying operating system. Why Java is not 100%Object-oriented? Java is not 100% Object-oriented becauseit makes use of eight primitive data types such as boolean, byte, char, int, float, double, long, short which are not objects. What are constructors in Java? In Java, constructorrefers to a block of codewhich is used to initialize an object. It must have the same name as that of the class. Also, it has no return type and it is automatically called when an object is created. There are two types of constructors: 1. Default Constructor: In Java, a default constructoris the one which does not take any inputs. In other words, default constructors are the no argument constructors which will be created by default in case you no other constructoris defined by the user. Its main purposeis to initialize the instance variables with the default values. Also, it is majorly used for object creation. 2. ParameterizedConstructor: The parameterized constructorin Java, is the constructorwhich is capable of initializing the instance variables with the provided values. In other words, the constructors which take the arguments are called parameterized constructors. Why pointers are not used in Java? Java doesn’tuse pointers because they are unsafe and increases the complexity of the program. Since, Java is known for its simplicity of code, adding the conceptof pointers will be contradicting. Moreover, since JVM is responsible for implicit memory allocation, thus in order to avoid direct access to memory by the user, pointers are discouraged in Java.
  • 2. What is the difference between an array and an array list? Array ArrayList Cannot contain values of different data types Can contain values of different data types. Size must be defined at the time of declaration Size can be dynamically changed Need to specify the index in order to add data No need to specify the index Arrays are not type parameterized Arraylists are type Arrays can contain primitive data types as well as objects Arraylists can contain only objects, no primitive data types are allowed What is a Map in Java? In Java, Map is an interface of Util package which maps unique keys to values. The Map interface is not a subset of the main Collection interface and thus it behaves little different from the other collection types. Below are a few of the characteristics of Map interface: 1. Map doesn’tcontain duplicate keys. 2. Each key can map at max one value. What is a classloaderin Java? The Java ClassLoader is a subsetof JVM (Java Virtual Machine) that is responsible for loading the class files. Whenever a Java program is executed it is first loaded by the classloader. Java provides three built-in classloaders: 1. Bootstrap ClassLoader 2. Extension ClassLoader 3. System/Application ClassLoader
  • 3. What are access modifiers in Java? In Java, access modifiers are special keywords which are used to restrict the access of a class, constructor, data member and method in another class. Java supports four types of access modifiers: 1. Default 2. Private 3. Protected 4. Public Define a Java Class. A class in Java is a blueprint which includes all your data. A class contains fields (variables) and methods to describe the behavior of an object. Let’s have a look at the syntax of a class. 1 2 3 class Abc { member variables // class body methods} What is an objectin Java and how is it created? An object is a real-world entity that has a state and behavior. An object has three characteristics: 1. State 2. Behavior 3. Identity An object is created using the ‘new’ keyword. For example: ClassName obj= new ClassName();
  • 4. OOPS Java Interview Questions What is run time polymorphism and compile time polymorphism? Compile time polymorphism is method overloading whereas Runtime time polymorphism is done using inheritance and interface. In Java, runtime polymorphism or dynamic method dispatch 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. Let’s take a look at the example below to understand it better. What is abstractionin Java? Abstraction refers to the quality of dealing with ideas rather than events. It basically deals with hiding the details and showing the essential things to the user. Thus you can say that abstraction in Java is the process ofhiding the implementation details from the user and revealing only the functionality to them. Abstraction can be achieved in two ways: 1. Abstract Classes (0-100% of abstraction can be achieved) 2. Interfaces (100% of abstraction can be achieved) What do you mean by an interface in Java? An interface in Java is a blueprint of a class or you can say it is a collection of abstract methods and static constants. In an interface, each method is public and abstract but it does not contain any constructor. Thus, interface basically is a group of related methods with empty bodies. Example: public interface Animal { public void eat(); public void sleep(); public void run(); }
  • 5. What is inheritance in Java? Inheritance in Java is the conceptwhere the properties of one class can be inherited by the other. It helps to reuse the codeand establish a relationship between different classes. Inheritance is performed between two types of classes: 1. Parent class (Super or Base class) 2. Child class (Subclass or Derived class) A class which inherits the properties is known as Child Class whereas a class whose properties are inherited is known as Parent class. What are the different types of inheritance in Java? Java supports four types of inheritance which are: 1. Single Inheritance: In single inheritance, one class inherits the properties of another i.e there will be only one parent as well as one child class. 2. Multilevel Inheritance: When a class is derived from a class which is also derived from another class, i.e. a class having more than one parent class but at different levels, such type of inheritance is called Multilevel Inheritance. 3. HierarchicalInheritance: When a class has more than one child classes (subclasses)or in other words, more than one child classes have the same parent class, then such kind of inheritance is known as hierarchical. 4. Hybrid Inheritance: Hybrid inheritance is a combination of two or more types of inheritance. What is method overloading and method overriding? Method Overloading :  In Method Overloading, Methods of the same class shares the same name but each method must have a different number of parameters or parameters having different types and order.  Method Overloading is to “add”or “extend” more to the method’s behavior.  It is a compile-time polymorphism.  The methods must have a different signature.  It may or may not need inheritance in Method Overloading.
  • 6. Method Overriding:  In Method Overriding, the subclass has the same method with the same name and exactly the same number and type of parameters and same return type as a superclass.  Method Overriding is to “Change” existing behavior of the method.  It is a run time polymorphism.  The methods must have the same signature.  It always requires inheritance in Method Overriding. What is multiple inheritance? Is it supported by Java? If a child class inherits the property from multiple classes is known as multiple inheritance. Java does not allow to extend multiple classes. The problem with multiple inheritance is that if multiple parent classes have the same method name, then at runtime it becomes difficult for the compiler to decide which method to execute from the child class. Therefore, Java doesn’tsupportmultiple inheritance. The problem is commonly referred to as Diamond Problem. In case you are facing any challenges with these java interview questions, please comment on your problems in the section below. What is encapsulationin Java? Encapsulation is a mechanism where you bind your data(variables) and code(methods)together as a single unit. Here, the data is hidden from the outer world and can be accessed only via current class methods. This helps in protecting the data from any unnecessary modification. We can achieve encapsulation in Java by:  Declaring the variables of a class as private.  Providing public setter and getter methods to modify and view the values of the variables.
  • 7. Servlets – Java Interview Questions What is RequestDispatcher? 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() What is the life-cycle of a servlet? There are 5 stages in the lifecycle of a servlet: 1. Servlet is loaded 2. Servlet is instantiated 3. Servlet is initialized 4. Service the request 5. Servlet is destroyed . What are the different methods of sessionmanagementin servlets? Some of the common ways of session management in servlets are: 1. User Authentication 2. HTML Hidden Field 3. Cookies 4. URL Rewriting 5. Session Management API
  • 8. JDBC – Java Interview Questions What is JDBC Driver? JDBC Driver is a software componentthat enables java application to interact with the database. There are 4 types of JDBC drivers: 1. JDBC-ODBC bridge driver 2. Native-API driver (partially java driver) 3. Network Protocoldriver (fully java driver) 4. Thin driver (fully java driver) What are the JDBC API components? The java.sql package contains interfaces and classes for JDBC API. Interfaces:  Connection  Statement  PreparedStatement  ResultSet  ResultSetMetaData  DatabaseMetaData  CallableStatement etc. Classes:  DriverManager  Blob  Clob  Types  SQLException etc.
  • 9. What is the role of JDBC DriverManagerclass? The DriverManager class manages the registered drivers. It can be used to register and unregister drivers. It provides factory method that returns the instance of Connection. What is JDBC Connectioninterface? The Connection interface maintains a sessionwith the database. It can be used for transaction management. It provides factory methods that returns the instance of Statement, PreparedStatement, CallableStatement and DatabaseMetaData. What are the steps to connectto a database in java?  Registering the driver class  Creating connection  Creating statement  Executing queries  Closing connection What is JDBC DatabaseMetaDatainterface? The DatabaseMetaData interface returns the information of the database such as username, driver name, driver version, number of tables, number of views etc. Spring Framework – Java Interview Questions List some of the important annotations in annotation-basedSpring configuration. The important annotations are:  @Required  @Autowired  @Qualifier  @Resource  @PostConstruct  @PreDestroy
  • 10. What is autowiring in Spring? What are the autowiring modes? Autowiring enables the programmer to inject the bean automatically. We don’t need to write explicit injection logic. The autowiring modes are given below: No, by name, by type, constructor Name the types of transactionmanagement that Spring supports. Programmatic transaction management Declarative transaction management JSP – Java Interview Questions What are the different tags provided in JSTL? There are 5 type of JSTL tags. 1. core tags 2. sqltags 3. xml tags 4. internationalization tags 5. functions tags How to disable sessionin JSP? 1. <%@ page session=“false” %> Exception and Thread Java Interview Questions How can you handle Java exceptions? There are five keywords used to handle exceptions in Java: 1. try 2. catch 3. finally 4. throw 5. throws
  • 11. What are the important methods of Java Exception Class? String getMessage() String getLocalizedMessage() Synchronized Throwable getCause() String toString() void printStackTrace() What is OutOfMemoryError in Java? OutOfMemoryError is the subclass of java.lang.Error which generally occurs when our JVM runs out of memory. What are the two ways to create a thread? In Java, threads can be created in the following two ways:-  By implementing the Runnable interface.  By extending the Thread