Java interview questions & answers

What are the different Java interview questions you need to know?

1) What is the number of memory types allocated by JVM?

Many types:

1. Stack

2. Heap

3. Native Method Stack

4. Program Counter Register

5. Class(Method) Area

2) What is platform?

A system is generally the components or application atmosphere in which a program operates. There are two types of system software-based and hardware-based Java provides software-based system.

3) What gives Java its 'write once and run anywhere' nature?

The bytecode Java is collected to be a byte program code which is the advanced language between source program code and device program code. This byte program code is not system particular and hence can be fed to any system.

4) What is JIT compiler?

Just-In-Time(JIT) compiler: It is used to boost the efficiency. JIT gathers areas of the byte program code that have similar efficiency at once, and hence cuts down the amount of time required for collection. Here the term “compiler” represents an interpretator from the instruction set of a Java Virtual Machine (JVM) to the training set of a particular CPU.

5) What is classloader?

The classloader is a subsystem of JVM that is used to fill sessions and connections.There are various kinds of classloaders e.g. Bootstrap classloader, Expansion classloader, Program classloader, Plug-in classloader etc.

6) What is the distinction between JDK, JRE and JVM?


JRE stands for Java Runtime Environment and it is one of the procedure of JVM


JVM stands for Java Virtual Machine and the execution of Java byte code which is aided by the abstract machine by providing the runtime environment.


JDK stands for Java Development Kit and it is existing physically and it consists of JRE + development tools.

7) Is next, delete, exit, main or null keyword in Java?


8) Will the String array of Main method is empty or null; if any arguments are not provided on the command line?

It is empty, but not null.

9) What is difference between object oriented development language and object focused development language?

Object focused development different languages follow all the features of OOPs except Bequest. Examples of object oriented development different languages are JavaScript, VBScript etc.

10) What is constructor?

Constructor is just like an approach that is used to initialize situations of a product. It is invoked at the time of object development.

11) Does constructor come back any value?

yes, that is present example (You cannot use return type yet it gives a value).

12) Is constructor inherited?

No, constructor is not inherited

13) Can you make a constructor final?

No, constructor cannot be final

14) What is static variable?

It is used to relate the typical residence of all things (that is not exclusive for each object) e.g. company name of workers,college name of scholars etc.

It gets storage only once in education area at the time of sophistication running.

15) Why main method is static?

As it is not required for the object to instantiate a static method and if it was non static method, object is first created by jvm and then it calls the main function and it will lead to the problem of extra allocation of memory.

16) What is static block?

Static data member is initialized using this.

At the time of classloading it was executed before main method.

17) What is the goal of a default constructor?

The standard constructor provides the standard principles to the things. The Java compiler makes a standard constructor only if there is no constructor in the class

18) Can we perform a system without main() method?

Yes, one of the way is static block

 For more interview questions; you can learn java from the java tutorial questions given over here.