Show Menu

Java Interview Questions Cheat Sheet by

A cheat sheet for the most frequently asked Java Interview Questions

Main Features of Java

Object Oriented
Platform Indepe­ndent

Principles of OOP

Abstra­ction means using simple things to represent complexity using object, classes, and variables.
This is the practice of keeping fields within a class private, then providing access to them via public methods. It’s a protective barrier that keeps the data and code safe within the class itself.
It lets progra­mmers create new classes that share some of the attributes of existing classes. This lets us build on previous work without reinve­nting the wheel.
Polymo­rphism refers to any entity whether it is a method or a constr­uctor or an operator which takes many forms or can be used for multiple tasks.

Multit­hreaded Progra­mming

Multit­hreaded progra­mming is one of the key features of java which allows multiple threads to execute their task simult­ane­ously.

There are two ways to create threads in Java
a) by extending the Thread class
b) by implem­enting the Runnable interface

Final, Finally, Finalize

Makes a variable, method, or class unchan­geable.
Exception handling after success or failure during a try catch block.
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.


Inheri­tance is one of the key principle of object oriented progra­mming. Through inheri­tance, one class can inherit the properties of another class. The class from which properties are inherited is called super class and the class to which properties are inherited is called sub class.

Does Java support multiple inheri­tance?
Java supports multiple inheri­tance but only through interf­aces. That means a class can implement more than one interfaces but can not extend more than one class.

Constr­uctor & Method Overlo­ading

A class can have any number of constr­uctors. These constr­uctors will have different list of arguments. It is called constr­uctor overlo­ading. Constr­uctor overlo­ading provides different ways to instan­tiate a class.

If a class has more than one method with same name but with different list of arguments, then it is called method overlo­ading.


If a super class method is modified in the sub class then it is called method overri­ding.

Abstract Classes

An abstract class is a class which cannot be instan­tiated. An abstract class is used by creating an inheriting subclass that can be instan­tiated. An abstract class does a few things for the inheriting subclass:

1.Define methods which can be used by the inheriting subclass.
2.Define abstract methods which the inheriting subclass must implement.
3.Provide a common interface which allows the subclass to be interc­hanged with all other subcla­sses.

Exception Handling

The code to be monitored for exceptions will be kept in this block.
If any exceptions occurred in try block, those exceptions will be caught by this block.
This block will be always executed whether exception is raised or not and raised exceptions are caught or not.

Checked & Unchecked Exceptions

Known and checked at compile time.
Known at Runtime, unknown at compile time.

Static & Non-Static Methods

Static method is common to all instances of a class. Static methods are stored in the class memory. Where as non-static methods are stored in the object memory. Each instance of a class will have their own copy of non-static methods.


Synchr­oni­zation is a way of contro­lling the access of a method or a block by multiple threads. Only one thread can enter into a method or a block which has been declared as synchr­onized. Synchr­oni­zation is one of the way to achieve thread safety.

Garbage Collection

Removing unwanted objects or abandoned objects from the memory is called garbage collec­tion. Garbage collection is done automa­tically in java. You need not to remove the unwanted objects explic­itly. Garbage collector thread does this for you.


Cloning is a process of creating an exact copy of an existing object in the memory. Cloning may be shallow or deep. In java, clone() method is used to create a clone of an object.


A Java interface is a bit like a class, except a Java interface can only contain method signatures and fields. An Java interface cannot contain an implem­ent­ation of the methods, only the signature (name, parameters and except­ions) of the method.

You can use interfaces in Java as a way to achieve polymo­rphism.


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Selenium WebDriver Cheat Sheet Cheat Sheet
          Cypressio Cheat Sheet
          ISTQB Test Automation Engineering Cheat Sheet

          More Cheat Sheets by sdm7306