INTERVIEW QUESTIONS

Java Interview Questions

Practice Java prompts by theme and build clearer interview answers.

Practice by topicRole and skill lensesClear answer prompts

Showing 52 practice prompts

✦

JAVA

What are the core principles of Object-Oriented Programming (OOP) in Java?

The four pillars of OOP are: 1) Encapsulation: Bundling state and methods together and restricting direct access via access modifiers (`private`, `protected`, `public`). 2) Inheritance: Allowing subclasses to inherit fields and methods from superclasses (`extends`). 3) Polymorphism: The ability of objects to take multiple forms through method overloading (compile-time) and method overriding (runtime). 4) Abstraction: Hiding implementation details and exposing only essential interfaces via `abstract` classes and `interface` declarations.
◦ fundamentals
✦

JAVA

What is the difference between JDK, JRE, and JVM?

JVM (Java Virtual Machine) is the abstract computing machine that executes compiled Java bytecode (`.class` files). JRE (Java Runtime Environment) bundles the JVM along with core Java class libraries required to run Java applications. JDK (Java Development Kit) is the complete development environment containing the JRE, compiler (`javac`), archiver (`jar`), and debugging tools needed to compile and build Java programs.
◦ fundamentals
✦

JAVA

What is the difference between an abstract class and an interface in modern Java?

An abstract class can declare instance variables, constructors, and maintain state, but a class can only extend one abstract class (single inheritance). An interface cannot maintain instance state and historically only declared abstract methods. Since Java 8+, interfaces support `default` and `static` methods, and since Java 9 support `private` methods. A class can implement multiple interfaces.
◦ fundamentals
✦

JAVA

Why is `String` immutable in Java?

Strings are immutable for: 1) Security: Sensitive data like passwords, network connections, and URLs cannot be modified maliciously once verified. 2) Thread safety: Immutable objects are inherently thread-safe and can be shared across threads without synchronization. 3) Caching & String Pool: Immutability enables the JVM String Pool, saving memory. 4) Hash code caching: The hash code is calculated once at creation and cached, making hash table lookups fast.
◦ fundamentals
✦

JAVA

What is the difference between `==` and `.equals()` in Java?

`==` is a reference comparison operator that checks whether two variable references point to the exact same memory address on the heap (or compares primitive values directly). `.equals()` is a method inherited from `Object` intended to compare logical state/equality between two objects (e.g., comparing string characters or field values).
◦ fundamentals
…

Your next interview is closer than you think.

Practice smarter and land better opportunities.

✓ Start with the free plan✓ No credit card✓ Cancel anytime
Start preparing free