700 Java interview questions and answers

Java 1   Java 2   Java 3   Java 4   Java 5   Java 6   Java 7   Java 8   Java 9   Java 10   Java 11   Java 12   Java 13   Java 14   Java 15   Java 16   Java 17   Java 18   Java 19   Java 20   Java 21  Java 22

Explain the difference between Java and JavaScript.
Explain how to obtain a performance profile of my Java Program.
Explain the purpose of the executable files that have an extra _g at the end of their names, e.g. java_g.
If Java is platform independent, why doesn't it run on all platforms?
Explain how to access native operating system calls from my Java program.
How do we create and use sockets in Java?
Explain how to send data from my Java program to a CGI program.
Explain the difference between a URL instance and a URLConnection instance.
How do I read a line of input at a time in Java?
Why is thread synchronization important for multithreaded programs?
Explain how to create a thread and start it running.
When should we use an event adapter class?
Explain the component and container classes.
What is the difference between a runtime exception and a plain exception?
Can you explain in brief life cycle for stateless and stateful beans?
What is Passivation and Activation in EJB?
How do we implement caching in JSP?
Explain the different Authentication options available in Servlets.
How can we use beans in JSP?
Explain the difference between JavaBeans and taglib directives.
Explain the different scopes an object can have in a JSP page.
Explain the use of Externalization interface.
Explain widening conversion and Narrowing conversion.
How do we implement deep cloning?  

Core Java  interview test (72 questions) new
-By Pradip Patil, Lecturer IIMP MCA

Java  (20 questions) new
-By Pradip Patil, Lecturer IIMP MCA

Download Java interview questions and answers pdf 

Java interview questions and answers for freshers and experienced

Java features

Simple, Object-Oriented, Robust, Distributed, Portable, Interpreted, Multithreaded, Platform Independent, Secure...........
Read answer

Java program execution

What is JVM? Explain its roles and functions.
Explain why Java is called as Platform independent language. Explain how Java executable executes on any platform where JVM is available...................
Read answer

Java architecture

Java programming language, Java class file format, Java Application Programming Interface, Java virtual machine.............
Read answer

Java class

Explain the features of Java class. Explain Fields, Methods, and Access Levels.
What are accessors and mutator methods in a Java class? Explain with example for each.
Explain the importance of 'this' reference. Write a code to depicts the use of 'this' reference
Explain static variables and static methods in Java. Provide an example to explain them..................
Read answer

Java constructors

What is a constructor? Explain the differences between methods and constructor.
Differences between constructors and methods.
Write code to depict the use of constructor.....................
Read answer

Java class member

What is instance members? Explain with an example
What is instance variable? Explain with an example
What is instance method? Explain with an example
What is static member? Explain with an example
What is static variable? Explain with an example......................
Read answer

Java packages

What are Java packages? Explain the importance of Java packages.
Steps for creating a package in Java
Explain the packages access specifier, i.e. private, protected, public, default.............
Read answer

Java garbage collector

Explain Java Garbage collector. Why garbage collection? Brief explanation of Garbage collection algorithms.
Explain the importance of finalizers in Java. Write code to depict the uses of finalizers in Java...............
Read answer

Java super keyword

Explain the importance of 'super' keyword in Java. Write code to depict the uses of 'super' keyword - The keyword ‘super’ is used for referring parent class instance....................
Read answer

Java overloading & overriding

Define Method overloading. Explain its uses. Provide a code sample to explain the uses of Method overloading
Define Method overriding. Explain its uses. Provide a code sample to explain the uses of Method overloading
Difference between overloading and overriding.......................
Read answer

Java string class

Describe Java string class. Explain methods of Java string class. Explain the characteristics of StringBuffer class - String Class: The String class is immutable, The contents of the String object can not be changed, String class is final class. That implies it can not have sub classes......................
Read answer

Java inner classes

What is Java inner class? Explain the types of inner classes, i.e. Static member classes, Member classes, Local classes, Anonymous classes
Need of inner class in context with adapter classes
Explain few Wrapper Classes Methods...............
Read answer

Java reflection class

Explain about Java reflection class.
Write a code sample to depict the uses of Java reflection class.........
Read answer

Java swing

What is Swing? Explain the need of Swing.
Write some important features of Swing.
Describe Java Swing class hierarchy.
Explain the need of Layout manager...........
Read answer

Java layout manager

Explain different layout manager in Java. - A layout manager organizes the objects in a container, Different layouts are used to organize or to arrange objects.............
Read answer

Java exception handling

Explain the need of Exception handling.
Explain the Exceptions categories, i.e. checked and unchecked exceptions.
Provide the general form of Exception handling constructs with explanation
What is user defined Exception? Explain with an example............
Read answer

Java multithreading

What is Multithreading? Explain the life cycle of a thread.
Explain how to use thread class for Multithreading in Java. Explain with an example.
What is Runnable interface? Explain how to use Runnable interface for Multithreading.
What are the methods of thread class in java? Explain them
Can your explain thread priorities?..............
Read answer

Java file handling

Explain the use of Streams.
Difference between Stream classes and Reader writer classes
Explain and demonstrate the use of File, RandomAccessFile classes.
Explain the use of Reader and Writer classes..............
Read answer

Java utility classes

What is object Serialization? Explain the use of Persisting object.
Depict the step of using object Deserialization.....................
Read answer

Java socket programming

What is socket? Explain the features of socket.
Explain the characteristics of Java socket class.
Explain ServerSocket class with an example
Explain InetAddress class with an example
Explain DatagramSocket class with an example
Explain DatagramPacket class with an example.............
Read answer


Purposes of JDBC API
Describe 4 types of JDBC drivers and their characteristics with usages.
State the functionalities of important classes in JDBC packages.
Explain how to use JDBC statement to execute SQL queries. Show in an example
Explain how to use Prepared Statement to execute parameterized queries. Show in an example
What is JDBC Callable Statement?
What is batch updates in JDBC? Explain with an example......................
Read answer

Java 1   Java 2   Java 3   Java 4   Java 5   Java 6   Java 7   Java 8   Java 9   Java 10   Java 11   Java 12   Java 13   Java 14   Java 15   Java 16   Java 17   Java 18   Java 19   Java 20   Java 21  Java 22

Write your comment - Share Knowledge and Experience

Discussion Board
java programming papers pune university


kajal jadhav 04-18-2015 12:35 AM

java interview Questions

Here's some more java questions:

1) Junior java developer
a) Basic ocjp (former scjp) questions:
– What does static, final mean, purposes;
– How many accesibility modifiers exist? Please describe them.
– Why do you need a main method?
– How many constructors can you have?
– Define overwriting and overloading
– Give java API implementations for overwriting and overloading
– Describe the String class – unique properties
– StringBuilder vs StringBuffer
– Collections : please describe, give some examples and compare them to eachother
– ArrayList vs Vector
– HashMap vs HashTable
– What’s a tree
– What’s a map
– Multithreading: describe the management in java
– What’s a semaphone?
– How many states are there for threads?
– Describe the usage for synchronized word (2)
– Serialization in java – a descrition and usage
– Garbage collection in java – description and usage
– Can you guarantee the garbage collection process?
b) Simple design pattern questions:
– Singleton please describe main features and coding
– Factory please describe main features and coding
– Have you used others? please describe them

2) Intermediate and Senior level – depending on rate of good responses, additional questions to 1):


Bogdan 08-1-2012 10:34 AM

Java interview questions and answers

Explain the importance of DriverManager.

The basic service to manage set of JDBC drivers.

What are the methods in Object?

clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString

Define a nested class.

If all the methods of a inner class is static then it is a nested class.

What is garbage collection?

Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process

Difference between LinkedList and ArrayList.

LinkedList are meant for sequential accessing.

ArrayList are meant for random accessing.

Define a package.

Packages provides wide namespace ability and allows to group set of classes into a single unit.

Raj 12-5-2011 03:10 AM

Java interview questions and answers

Explain the significance of ListIterator.

Using ListIterator you can iterate back and forth.

Can you explain inner class.

If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class.

Can you explain the meaning of aggregation and composition

Aggregation - It is a special type of composition. If you expose all the methods of a composite class and route the method call to the composite method through its

reference, then it is called aggregation.

Composition - Holding the reference of the other class within some other class is known as composition.

Is it possible to instantiate the Math class?

You can’t instantiate the math class.

Pankaj 12-5-2011 03:10 AM

Java interview questions and answers

Define Locale.

A Locale object represents a specific geographical, political, or cultural region.

How will you load a specific locale?

By using ResourceBundle.getBundle(…);

Is JVM a compiler or an interpreter?


Can you explain the usages of Class.forName()?

It loads the class into the ClassLoader. It returns the Class. Using that you can get the instance ( “class-instance”.newInstance() ).

Inq adds a question: Expain the reason for each keyword of

public static void main(String args[])

Akash 12-5-2011 03:10 AM

Java interview questions and answers

Define reflection.

Reflection allows programmatic access to information about the fields, methods and constructors of loaded classes.

Can you tell me range of byte?

128 to 127

How to invoke external process in Java.


What is the best way to findout the time/memory consuming process?

By using profiler

Rakesh 12-5-2011 03:09 AM

Java interview questions and answers

What is skeleton and stub? Explain their purposes.

Stub is a client side representation of the server, which takes care of communicating with the remote server.

What kind of thread is the Garbage collector thread?

Daemon thread

Explain the purpose of Void class.

The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.

Nitin 12-5-2011 03:09 AM

Java interview questions and answers

Explain the importance of finalize method.

Finalize method cleans up some resources before it get garbage collected.

Define mutable object and immutable object.

The value of Mutable object is changeable.
Ex., StringBuffer

The value of an immutable object can't be changed

Ex., String, Integer, Float

What are the base class for Error and Exception?


Dharam 12-5-2011 03:09 AM

Java interview questions and answers

Difference between string and stringbuffer object.

String is an immutable object.

StringBuffer is a mutable object.

Define daemon thread.

Daemon thread are the threads which can run without user intervention.
The JVM can exit when there are daemon thread by killing them abruptly.

Define a DatabaseMetaData.

It represents comprehensive information about the database as a whole.

Jitu 12-5-2011 03:08 AM

Java interview

Explain preemptive scheduling and time slicing.

In preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence.

In time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks.

Explain the different scopes for Java variables.

3 scopes of Java variables are defined below:


Initialized to default values at the time of creation of object, and remain accessible as long as the object accessible.


Defined within a method and remain accessbile only during the course of method excecution and fall out of scope When the method finishes



Static variables are the class level variables.
Static variables are initialized when the class is loaded in JVM for the first time and remain there as long as the class remains loaded.
Static variables are not tied to any particular object instance.

Akash 11-23-2011 02:26 AM

Java interview questions and answers

Explain the purpose of finalization.

It provides an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.

Explain the importance of daemon thread.

Daemon thread is a low priority thread.
It runs intermittently in the back ground doing the garbage collection operation for the java runtime system.

A daemon thread is created using setDaemon method.

Synchronized methods and synchronized statements.

Synchronized methods

Methods that are used to control access to an object.
A thread only executes a synchronized method after it has acquired the lock for the method's object or class.

Synchronized statements

They are similar to synchronized methods.
A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

Nitin 11-23-2011 01:31 AM

Java interview questions and answers

What are the way of using thread?

Can be implemented by using runnable interface
By inheriting from the Thread class.

Difference between a constructor and a method.


A constructor is a member function of a class that is used to create objects of that class.
It has the same name as the class itself.
It has no return type, and is invoked using the new operator.


A method is an ordinary member function of a class.
It has its own name, a return type, and is invoked using the dot operator.

Explain how to serialize an object to a file.

The class whose instances are to be serialized should implement an interface Serializable, pass the instance to the ObjectOutputStream which is connected to a fileoutputstream. This will save the object to a file.

Naveen 11-23-2011 01:25 AM

Java questions and answers

Access Specifiers in Java.

Public- public classes, methods, and fields can be accessed from everywhere.


Protected methods and fields can only be accessed within the same class, within its subclasses, and within classes of the same package.

Default(no specifier)

Such a class, method, or field will be accessible from inside the same package to which the class, method, or field belongs, but not from outside this package.


Private methods and fields can only be accessed within the same class.
Private methods and fields are not visible within subclasses
They are not inherited by subclasses.

Explain static methods.

Static methods are declared with the keyword static as modifier.
They are called Static because they affect a class as a whole, not a particular instance of the class.
They are always invoked without reference to a particular instance of a class.

Restrictions of using static methods:

It can only call other static methods.
It must only access static data.
It cannot reference to the current object using keywords super or this.

Priya 11-23-2011 12:55 AM

Java interview questions

Can you tell me the main Implementations of the Set interface?


Explain the importance of HashSet.

It is an unsorted, unordered Set.
It uses the hashcode of the object being inserted.
You can use it when you want a collection with no duplicates and you don’t care about order when you iterate through it.

Explain the importance of TreeSet.

It is a set implementation keeping the elements in sorted order.
The elements are sorted according to the natural order of elements or by the comparator provided at creation time.

Tina 11-23-2011 12:46 AM

Java interview questions and answers

Define native method.

A native method is implemented in a language other than Java.

Explain explicit casting.

In Explicit casting, the complier are specifically informed about transforming the object.


long a = 890.20;

int b = (int) a; //Explicit casting

Explain implicit casting.

Assigning one entity to another without any transformation guidance to the compiler is implicit casting.
This type of casting is not permitted in all kinds of transformations and may not work for all scenarios.


int a = 6000;

long b = a; //Implicit casting

Explain reflection API

Reflection is the process of introspecting the features and state of a class at runtime and dynamically manipulate at run time.
This is supported using Reflection API with built-in classes like Class, Method, Fields, Constructors etc.

Example: Using Java Reflection API we can get the class name, by using the getName method.

Rajeev 11-22-2011 04:07 AM

Java interview questions and answers

Explain the importance of Java Virtual Machine (JVM).

It converts .java file into .class file by using Compiler and Interpreter reads byte codes.

Explain the different types of access modifiers in Java.

They determine the type of access to the member of a class.


-Public : accessible to all classes
-Protected : accessible to the classes within the same package and any subclasses.
-Private : accessible only to the class to which they belong
-Default : accessible to the class to which they belong and to subclasses within the same package

Why there are no global variables in Java?

Global variables are globally accessible and hence can create collisions in namespace.

What is the Java API?

It a large collection of software components that provide capabilities, such as graphical user interface (GUI) widgets.

Rajeev 11-22-2011 03:48 AM

Java interview questions and answers

Explain StringTokenizer.

It is utility class that are used to break up string.


StringTokenizer str = new StringTokenizer(“Welcome”);

while (str.hasMoreTokens()) {



Nadeem 11-22-2011 03:42 AM

Java interview questions and answers

Difference between the boolean & operator and the && operator.

When boolean & operator is evaluated, both operands are evaluated
&& operator is a short cut operator.

When && operator is evaluated, the first operand is evaluated.
When first operand returns a value of true then the second operand is evaluated.
When first operand evaluates to false, the evaluation of the second operand is skipped.

Nadeem 11-22-2011 03:40 AM

Java interview questions

Does Java support pointers?

Java doesn't support the usage of pointers. Improper handling of pointers leads to memory leaks which is why pointer concept hasn't found place in Java.

Swing and Awt

AWT are heavy-weight componenets.
Swings are light-weight components and this is reason why swing works faster than AWT.

Pass by reference and passby value

Pass By Reference is the passing the address itself rather than passing the value.
Passby Value is passing a copy of the value to be passed.

Rakesh S 11-4-2011 01:26 AM

Java interview questions

Abstract class

It must be extended or subclassed.
It acts as a template.
It may contain static data.
A class may be declared abstract even if it has no abstract methodsand this prevents it from being instantiated.

Annie 11-4-2011 01:21 AM



Interview questions
Home | Want a Job? Submit Key Skills | My key skills | About us | Sitemap | Contact us