Java interview questions and answers

Java interview

Dear job Aspirants, here we are providing you with all the important Java interview questions and answers that will help you out when you attend an interview. The questions mentioned below include all core java, oops concepts and advanced java important questions. These java interview questions are prepared after several analysis and through our experienced java experts.

 Core Java Interview questions

core java interview questions
core java

Tell me something about Java?

Java is a high-level programming language developed by Sun Microsystems in 1995. Java runs on different platforms, such as Windows, Mac OS, and the various versions of UNIX. Java is Platform independent language and an object oriented language.

What is meant by platform independence?

Java code once written and compiled on a platform, then it can be executed on any platform using the java .class file.

What is JVM?

JVM can be abbreviated as Java Virtual Machine, JVM is the runtime environment in which the compiled java class files run.

Is JVM platform independent?

JVM’s are not platform independent, they are platform specific, they are run time implementation provided by the Vendor.

What is JRE?

JRE can be abbreviated as Java Runtime environment, it is the implementation of JVM.

What is JDK?

JDK can be abbreviated as Java Development Kit, it is the physical part of Java, it contains all the development tools along with JRE.

What is the difference between JVM, JRE and JDK?

JVM can be abbreviated as Java Virtual Machine, JVM is the runtime environment in which the compiled java class files run.

JRE can be abbreviated as Java Runtime environment, it is the implementation of JVM.

JDK can be abbreviated as Java Development Kit, it is the physical part of Java, it contains all the development tools along with JRE.

What is JIT compiler?

JIT is abbreviated as Just in time, JIT compiler is used to improve the performance speed. JIT compiles the code that has same functionality at the same time and thus reducing the amount of time required to compile. Here compiler refers to translator, it translates instruction set of JVM to instruction set of Specific CPU.

What is the base class of all classes in Java?

Object class is the base class of all classes in Java.

What are pointers and does java support pointers?

Pointers handle reference to the memory location, these pointers are difficult to handle, thus Java doesn’t use pointers.

List any two Java IDE’s?

Eclipse and Netbeans.

What is an Object in Java?

Objects are the run time entity’s, object’s state is stored in fields and its behavior is expressed through methods.

What is an Class in Java?

A class is the collection of objects (or) class is the blue print from which objects are created. A class can contain methods and fields to show the behavior of the object.

What are the types of variables a class can hold?

A class can hold can hold class variable, instance variable and local variable.

What is meant by Local Variable?

Variables that are defined inside the methods or constructors or blocks are called as local variables. These variables are declared and initialized within the methods and these are destroyed once you come out of the method.

What is meant by class variable?

These variables are declared as static variables, these are declared outside the method but within the class.

What is meant by instance variable?

These variables are declared within the class but outside the method. These are not static.

What is meant by static variables?

The variables which are declared static are known as static variables, the value of the static variable remains same throughout the class.

What is meant by singleton class?

A class which contains only a single object is called as singleton class.

What is the return type of main() method?

Main() method doesn’t return anything, thus it is declared as void.

Why is main() method declared static?

As, main() method is called by JVM, before any class is  instantiated, thus it is Called as static.

Can we overload a main method?

Yes, you can overload a main() method, you can have any number of main methods with different method signature and class implementation.

Can we declare a main() method as final()?

Yes, you can declare a main()  method as final, inheriting classes will not be having its own main() class.

Can we declare a main() method as static public void main()?

Yes, you can declare, the placement of public and static doesn’t affect the code, but void should be placed before the main().

How can you define a variable as final in Java?

A variable can be defined as constant, if it is declared as both static and final variable.

Java oops interview questions and answers

oops interview questions
oops interview

Here, questions related to all the java oops concepts are covered, it includes, inheritance, polymorphism, abstraction, object, class, encapsulation, method overloading, overriding and many other java oops interview questions and answers.

What is inheritance?

Inheritance is the property in which a class acquires the properties of its parent class. It helps in code reusability.

What are the types of inheritance present in Java?

Single inheritance, Multilevel inheritance, Hierarchical inheritance and Hybrid inheritance.

Does java support multiple inheritance?

No, java doesn’t support multiple inheritance.

What is a Constructor?

Constructor is invoked at the time of object creation, every class has a default constructor, if we do not declare it explicitly, java compiler creates one for the class.

Can constructer be inherited?

No, constructer can’t be inherited.

Can you declare a constructor as Final?

No, you can’t declare a constructor as final.

What is static method?

Static method can be invoked without creating the object of that class, static methods can access the static data members and can change the value of it.

What is a static block?

Static block is used to initialize the static data member and it is executed before the main method.

Can we run a program without main() method?

Yes, you can execute through static block.

What is this keyword in Java?

This keyword is used to refer to the current object.

What is super keyword in Java?

Super keyword is used to refer the immediate parent class object.

What is polymorphism?

When a task is performed in multiple ways it is called as polymorphism. We use method overloading and method overriding to achieve polymorphism.

What is method Overriding?

If a subclass has the same implementation of a method as of the parent class method it is called as method overriding.

What is method overloading?

A method having the same signature but different arguments is known as method overloading. It increases the readability of the code.

What is Abstraction?

Abstraction is the process of hiding the internal details and showing the functionality is knows as abstraction. In java we achieve it using interfaces.

What is an interface?

A abstract class is implemented using interface as a class is extended using inheritance.

What is Encapsulation?

Encapsulation is the process of binding data and code together in to a single unit.

Advance Java Interview Questions and Answers

Advance java interview questions
Advance java interview

Here we will cover all the important java interview questions related to advance java, it includes, threads, java swings, Java servlets, xml processing and many other java advanced concepts are covered. This will make easy to learn and achieve the desired job you are looking for as a java developer.

What is transient variable in Java?

Transient variable cant be serialized.

Can a lock be acquired on class?

Yes, lock can be acquired on class.

What is meant by synchronization with respect to threads?

Synchronization is the capability to control the multiple threads to access the shared resources.

Is null a keyword in java?

No, null is not a keyword in java.

Through which method containers layout is specified?

To specify the containers layout we use setLayout() method.

When a thread terminates, in which state does it enter?

Whenever a thread terminates it enters the dead state.  

What are Vector cards in Java?

Vector cards helps in growing array of objects.

What is list interface?

List interface is used to provide support for ordered collections of objects.

 What is meant by an Iterator interface?

The Iterator interface is helpful in to stepping through the elements of a Collection.

Is sizeof a keyword in java?

Sizeof is not a keyword but an operator in java.

What is the difference between sleep() and yield() method?

When a sleep() method is invoked it returns back to the waiting state and when a yield() method is invoked it returns back to ready state.

What is a wrapper class in Java?

A wrapper class allows primitive data types to be accessed as objects.

Which class is the immediate super class of Applet class?

Panel is the immediate super class of applet class.

Which class is the immediate super class of Dialog class?

Window is the immediate super class of Dialog class.

What is clipping is java?

Clipping confines paint operations to specific area or specific shape.

What is meant by a native method?

Native methods are implemented in language other than java.


Here we conclude our post on Java interview questions and answers. We have covered all the important areas in which most questions are expected, we can’t be shore that these questions can be asked or may not be asked by the interviewer, if you like the post, do share and like. If you have any queries feel free to comment in the space provided.

Leave a Reply

Your email address will not be published. Required fields are marked *