Core Java Interview Questions

A curated selection of some of the most common Java interview questions found in the industry.

Any aspiring Java programmer will need to have the fundamentals of the language well ingrained into their memory. After conducting many interviews for Java based software engineering candidates, I have decided to compile a list of the most commonly asked questions. These are in no particular order and have answers provided. Memorization and full understanding these questions will greatly increase your chances of moving on to consecutive interview rounds.

What is the static modifier in Java?

  • The static modifier in Java is used to associate a method or variable with a class rather than with a specific instance of that class. It enables shared access to the method or variable among all instances of the class, and it can also be accessed directly using the class name.
  • The static keyword denotes that a member variable or method can be accessed, without requiring an instantiation of the class to which it belongs. A user cannot override static methods in Java, because method overriding is based upon dynamic binding at runtime and static methods are statically binded at compile time. A static method is not associated with any instance of a class so the concept is not applicable
  • Common use cases for static members include defining utility methods in utility classes, declaring constants, or maintaining class-level data, such as counters for instances created.

What are restrictions on static methods?

  • Static methods cannot access instance level data, only static variables.
  • Static methods cannot be overridden.
  • Static methods can only call other static methods.

What is stored on Heap and Stack memory in Java?

  • Heap: All instantiated objects are stored on the heap in java.
  • Stack: All reference variables, methods, and local variables are stored on the stack.

What is an interface in Java?

  1. An interface is a programming construct that defines a contract or set of method signatures that a class must adhere to if its implements that interface. It servers as a blueprint for a class, specifying a set of behaviors or methods a class can implements.

What benefit do interfaces provide?

  1. Interfaces allow for the abstraction of behavior promoting code modularity and a separation of concerns. They enable polymorphism by allows objects of different classes to implement the same interface and be treated interchangeably enhancing code flexibility and reusability.
  2. Interfaces support multiple inheritance by implementing more than one interface. This add flexibility by allowing developers to design complex class hierarchies and reuse code effectively.
  3. Interfaces serve as a contract that a certain set of methods will be available to a class. This ensures classes conform to a particular structure and is vital for maintaining large codebases and facilitating collaboration among developers.

What is the Java Virtual Machine (JVM)

  1. The Java Virtual Machine (JVM) is a pivotal component of the Java programming language. The JVM takes compiled Java source code (bytecode) and translates it into machine code that the underlying hardware and operating system can understand. This translation happens on the fly, allowing Java programs to be platform-independent, meaning they can run on any device or operating system equipped with a compatible JVM.

What is the difference between the JDK and JRE?

  1. The Java Development Kit (JDK) and the Java Runtime Environment (JRE) are two essential components of the Java ecosystem. The JDK is a comprehensive package that includes everything needed for Java development, such as the Java compiler (javac), debugger, libraries, and development tools. It is used by developers to write, compile, and debug Java applications. On the other hand, the JRE is a more streamlined runtime environment that is used to run Java applications but lacks the development tools present in the JDK. Essentially, the JRE contains the Java Virtual Machine (JVM) along with core libraries and resources required to execute Java applications. In summary, while the JDK is for Java development, encompassing tools and compilers, the JRE is for end-users who simply need to run Java applications and don’t require development tools.


Study these questions thoroughly to be well prepared for your next technical interview. Knowledge of this information will not only increase your chances of landing a job, but will also provide a insight into how applications are working under the hood.