Java Interview Questions
What does a default member mean?
A default member is one that does not have any of the modifiers like public, protected or private.
If a class contains more than one or more final methods must the class be declared final?
No, it not required to make the class final if it has any final methods. But if a class is final it is not necessary that the methods should be declared as final.
What is the difference between String class and StringBuffer class?
A String object is immutable which means the object cannot be changed. But in the case of StringBuffer class it provides the option of modifying String.
What does Java Sandbox term mean?
Sandbox is the term used to describe the security model used by java when running programs. This model provides an interface between a java application and operating
system resource that can be configured by end user.
What is a Thread?
Thread is a light weight process. In java thread is the current program in execution. JVM allows an application to have multiple threads of execution thus supporting
What are the two approaches for writing code that create a new Thread of control?
The two approaches are:
- Extend the Thread class in java.lang package and override the run() method
- Implement the Runnable interface and implement run() method
What method is used to start the execution of the thread?
start() method is used to start the execution of the thread. This inturn calls the run() method.
What is the purpose of synchronized keyword?
The keyword ‘synchronized’ provides a solution to protect object data from being accessed by more than one thread, which could make the object have an invalid state.
What is collection?
A collection is a group of objects which will be treated as a single object.
What is an Iterator?
Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows us to walk through a collection of
objects, operating on each object in turn. Generally it is not advisable to modify the collection itself while traversing an Iterator.
Difference between hash map and hash table?
The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. (HashMap allows null values as key and value whereas
Hashtable does not allow). HashMap does not guarantee that the order of the map will remain constant over time. HashMap is unsynchronized and Hashtable is synchronized
What is serialization?
Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream.
Difference between swing and AWT?
Both the AWT and swing supports GUI programming in Java. AWT are heavy-weight components as it has the native code called peer. Swings are light-weight components as
it does not have the native code but built entirely in java programming language. Hence swing works faster than AWT.
What is the difference between ServerSocket and DatagramSocket transport protocol?
DatagramSocket is used for UDP communication which is a connectionless protocol whereas ServerSocket is used for TCP communication which is a connection oriented
What are checked and unchecked Exception?
Checked exceptions are those which occur at compile time. Eg: IOException. Unchecked exceptions are those which occur at run time. Eg: StringIndexOutOfBoundsException.
- New to Java – Getting started tutorial
- Creating programs – Java Tutorial
- Methods and classes – Java Tutorial
- Blocks and overloading – Java Tutorial
- Input, Selection and Repetition
- How to create arrays and strings – Java tutorial
- Advanced array techniques – Java tutorial
- Creating applets – Java Tutorial
- Inheritance and class extensions – Java Tutorial
- Super classes and subclasses – Java Tutorial
- Abstract Class – Java Tutorial
- Introduction to Exception Handlers – Java tutorial
- Input and Output – Java tutorial
- New to Java – Introductory guide for beginners
- Getting started with Java
- Building Java 7 on Mac OS X
- What and How of java
- Java Interview Questions
- Java Aspects
- Java Enums
- Java Generics
- Java Annotations
- Autoboxing in Java
- Ten things a Java developer should know
- Java 8 Overview
- Default Methods in Java 8
- Lambda Expressions in Java 8
- Parallel Operations in Java 8
- Date and Time API in Java 8
- Top 5 Java Books for beginners