Java Interview Questions
1 .
What is the difference between a class and an object?
A class is a model for creating objects and does not exist physically. An object is anything that exists physically. Both the class & objects contain variables and  methods.
2 .
What are the principle concepts of OOPS?
There are four principle concepts upon which object oriented design and programming rest. They are:
Abstraction
Polymorphism
Inheritance
Encapsulation
3 .
What is Abstraction?
Abstraction refers to the act of representing essential features without including the background details or explanations.
4 .
What is Encapsulation?
Encapsulation is a technique used for hiding the properties and behaviors of an object and allowing outside access only as appropriate. It prevents other objects from directly altering or accessing the properties or methods of the encapsulated object.
5 .
What's singleton class ?
In object-oriented programming, a singleton class is a class that can have only one object (an instance of the class) at a time.
6 .
What is hash code and how can you find the hash code of an object?
Hash code is a unique identification number allotted to the objects by JVM. This hash code number is also called reference number which is created based on the location of the object in memory, and is unique for all objects except String objects.
The hashCode() method of ‘Object’ class in java.lang package is useful to find the hash code of an object.

7 .
Can we declare a class as ‘private’?
No, if we declare a class as private, then it is not available to java compiler and hence a compile time error occurs. But, inner classes can be declared as private.
8 .
Does constructor return any value?
yes, that is current class instance (You cannot use return type yet it returns a value).
9 .
When is a constructor called, before or after creating the object?
A constructor is called concurrently when the object creation is going on. JVM first allocates memory for the object and then executes the constructor to initialize the instance variables. By the time, object creation is completed; the constructor execution is also completed.
10 .
What is constructor overloading?
Writing two or more constructors with same name but difference in the parameters is called constructor overloading. Such constructors are used to perform different tasks.