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)

DOCX
100 Java questions FOR LOGIC BUILDING SOFTWARE.docx
PDF
Java Interview Questions
PDF
__ Java Technical round questions .pdf soo
PPTX
Suga java training_with_footer
DOCX
Java interview questions and answers for cognizant By Data Council Pune
PPTX
Java_Interview Qns
PDF
Java Faqs useful for freshers and experienced
PDF
Top 371 java fa qs useful for freshers and experienced
PPTX
Presentation2.ppt java basic core ppt .
PDF
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
PDF
1669617800196.pdf
PPTX
Nitish Chaulagai Java1.pptx
PDF
Java questions for interview
PDF
Top 30 Java Phone Interview Questions Answers for Freshers, 1 to 2 Years Expe...
PDF
Core Java Interview Questions PDF By ScholarHat
PPTX
25 java interview questions
DOC
Java interview questions
PDF
Java Basics Presentation
PDF
20 most important java programming interview questions
DOCX
100 Java questions FOR LOGIC BUILDING SOFTWARE.docx
Java Interview Questions
__ Java Technical round questions .pdf soo
Suga java training_with_footer
Java interview questions and answers for cognizant By Data Council Pune
Java_Interview Qns
Java Faqs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experienced
Presentation2.ppt java basic core ppt .
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
1669617800196.pdf
Nitish Chaulagai Java1.pptx
Java questions for interview
Top 30 Java Phone Interview Questions Answers for Freshers, 1 to 2 Years Expe...
Core Java Interview Questions PDF By ScholarHat
25 java interview questions
Java interview questions
Java Basics Presentation
20 most important java programming interview questions
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)

PPTX
AgentX UiPath Community Webinar series - Delhi
PDF
International Journal of Information Technology Convergence and Services (IJI...
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPT
Chapter 6 Design in software Engineeing.ppt
PPTX
TE-AI-Unit VI notes using planning model
PDF
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Principles of Food Science and Nutritions
PPTX
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
PDF
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
PDF
Queuing formulas to evaluate throughputs and servers
PDF
6th International Conference on Artificial Intelligence and Machine Learning ...
PPTX
Ship’s Structural Components.pptx 7.7 Mb
PPTX
anatomy of limbus and anterior chamber .pptx
PPT
SCOPE_~1- technology of green house and poyhouse
PPTX
Chapter----five---Resource Recovery.pptx
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
AgentX UiPath Community Webinar series - Delhi
International Journal of Information Technology Convergence and Services (IJI...
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Chapter 6 Design in software Engineeing.ppt
TE-AI-Unit VI notes using planning model
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Principles of Food Science and Nutritions
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
Queuing formulas to evaluate throughputs and servers
6th International Conference on Artificial Intelligence and Machine Learning ...
Ship’s Structural Components.pptx 7.7 Mb
anatomy of limbus and anterior chamber .pptx
SCOPE_~1- technology of green house and poyhouse
Chapter----five---Resource Recovery.pptx
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf

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