Top 10 Java Interview Questions for Beginners

Automation Tester who uses selenium with Java, has to know all core java concepts. and during interview most of the interviewers including me ask several core Java questions. here is most common asked interview questions.

  •  Why Java called platform independent?

JAVA is called as a platform independent programming language as it works on the principle “compile once, run everywhere”.

If you have written some code in JAVA and you have compiled that, you can execute the same code on any platform, the only thing you need is to install corresponding JVM(Java virtual machine).

  • What is the difference between an Interface and an Abstract class?

 1. An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract.

2. An abstract class is a class which may have the usual flavors of class members, but has some abstract methods.An interface has all public members and no implementation.

  • What is the purpose of garbage collection in Java?

The purpose of garbage collection is to identify and discard objects that are no longer needed by a program and reuse the resources again in the program.

  • What is HashMap and Map? and difference between them?

Map is Interface and Hashmap is class that implements Map.

HashMap allows null values as key and value whereas Hashtable doesnt allow.  HashMap is unsynchronized and Hashtable is synchronized.

  • State the significance of public, private, protected and default  access modifiers.

public : Public class is visible in other packages, field is visible everywhere.

private : Private Methods, variables are visible in same class and not avaialble in any other classs

protected : Is available to all classes in the same package and also available to all subclasses of the class that owns the protected feature.

default :What you get by default ie, without any access modifier .It means that it is visible to all within a particular package.

  • What is Final in Java?

A final class can’t be extended

 A final method can’t be overridden

 A Final Variable can not be change.

  • What is an abstract class?

    It serves as a template and it should be extend. A class that is abstract may not be instantiated (ie, you may not call its constructor), abstract class may contain static data. Any class with an abstract method is automatically abstract itself, and must be declared as such. A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.


  •  What is difference between Overloading and overwriting in Java?


Method signature should not be same.

It happen at time of code compilation, so it called compile time polymorphism.

Method can have any return type.

Method can have any access level.


Method signature should be same.

It happen on time of run time, so it called as run time polymorphism.

Method return type must be same as super class method

Method must have same or wide access level than super class method access level.


some more Java questions and answers are coming soon…

You might also like More from author