Java Developer Interview Questions and Answers, With a Scoring Rubric for Hiring Managers

Abinayasree C

Updated on March 2, 2023

Java Developer Interview Questions and Answers, With a Scoring Rubric for Hiring Managers

Abinayasree C

Updated on March 2, 2023

In this post

CREATE YOUR ACCOUNT

Accelerate the hiring of top talent

Make talent quality your leading analytic with skills-based hiring solution.

Get started

Most Java interviews fail in the same way. The interviewer asks “What is a HashMap?”, the candidate gives the textbook definition, and both leave the room knowing nothing new. Recall is cheap to fake and easy to prepare for. What separates Java developers is whether they can explain why something works, apply it to a real problem and name the tradeoff.

This guide gives you Java developer interview questions grouped by topic, with what a strong answer includes, what a weak one sounds like and a rubric to score both. Use it after candidates have cleared a knowledge screen such as the Java skill test, so interview time goes to depth instead of basics.

What a Java developer does today

Java still runs a large share of backend services, financial systems, Android apps and cloud workloads. A typical Java developer builds and maintains server side services, works with relational databases through SQL and ORM tools, designs object oriented code, writes tests and ships to cloud environments. Java 17, Java 21 and Java 25 are the recent long term support releases, so a candidate whose knowledge stops at Java 8 is working with a version released in 2014.

Skills to look for: core Java and the JVM, the collections framework, concurrency, relational databases with SQL and ORM, web services and REST APIs, a framework such as Spring Boot, object oriented design and test driven development.

How to score Java interview answers

Score every answer on the same four level scale. It keeps panels consistent and gives you something to compare when two interviewers disagree.

ScoreLevelWhat you hear
1RecallA definition, often memorized, with no example
2ExplainsCorrect reasoning about how it works
3AppliesA concrete example from their own work or a worked scenario
4JudgesNames tradeoffs, edge cases and when not to use it

A mid level hire should average 3 on core Java. Senior candidates should reach 4 on concurrency and design.

Core Java interview questions

1. How are arguments passed in Java?

Strong answer: Java is always pass by value. For objects, the value passed is a copy of the reference, so a method can change the object’s state but can’t make the caller’s variable point at a new object.

Red flag: “Primitives by value, objects by reference.”

2. What do you know about encapsulation and polymorphism?

Strong answer: encapsulation hides state behind methods so invariants can’t be broken from outside. Polymorphism lets one interface have many implementations, chosen at runtime through method overriding. Good candidates give an example from code they wrote.

Red flag: definitions with no example.

3. How do you differentiate runtime exceptions from checked exceptions?

Strong answer: checked exceptions must be declared or handled and represent recoverable conditions such as a missing file. Runtime exceptions signal programming errors such as a null reference and aren’t forced on the caller. Strong candidates have a view on when to wrap checked exceptions and why empty catch blocks are dangerous.

Red flag: catching Exception everywhere.

4. What are transient variables?

Strong answer: a field marked transient is skipped during Java serialization, used for passwords, caches or fields that can be recomputed. It returns to its default value after deserialization.

5. Is Java statically or dynamically typed?

Strong answer: Java is statically typed; types are checked at compile time. Dynamic languages such as Python check types at runtime. A candidate scoring 4 notes that var in Java 10 and later infers types but remains static.

6. What is garbage collection in Java?

Strong answer: the JVM reclaims memory from objects no longer reachable from GC roots. Strong candidates mention generational collection, name a collector such as G1 or ZGC, and describe a memory leak they’ve debugged, for example a static collection that keeps growing.

Red flag: “Java has no memory leaks.”

7. What are lambda expressions and why were they a big deal in Java 8?

Strong answer: lambdas are concise implementations of functional interfaces. With the Streams API they let developers write declarative collection processing and pass behavior as data. Strong candidates also know when a plain loop is clearer.

Collections, concurrency and design questions

8. How does ConcurrentHashMap differ from HashMap?

Strong answer: HashMap isn’t thread safe and allows one null key. ConcurrentHashMap supports concurrent reads and writes without locking the whole map, rejects null keys and values, and offers atomic operations such as computeIfAbsent. A score of 4 explains why wrapping a HashMap in synchronizedMap scales worse.

9. What is the difference between a thread and a process?

Strong answer: a process has its own memory space; threads share the memory of their process. Shared memory makes threads cheap to create and communicate but exposes race conditions, which is why visibility and synchronization matter.

10. How would you implement the Singleton pattern?

Strong answer: an enum singleton or the holder idiom, both thread safe without explicit locking. For example:

public final class Config {
    private Config() {}
    private static class Holder {
        static final Config INSTANCE = new Config();
    }
    public static Config get() { return Holder.INSTANCE; }
}

A candidate scoring 4 adds that singletons make testing harder and that dependency injection often removes the need.

11. What is the function of an object factory?

Strong answer: a factory hides how objects are created so callers depend on an interface, not a concrete class. Good examples: choosing an implementation from configuration or isolating creation logic for testing.

12. What are the characteristics of an ACID database system?

Strong answer: atomicity, consistency, isolation and durability, each explained with a transaction example. Strong candidates connect isolation levels to problems they’ve seen, such as dirty reads, and to how @Transactional behaves in Spring.

13. How would you detect a loop in a linked list?

Strong answer: Floyd’s cycle detection with a slow and a fast pointer, O(n) time and O(1) space. A HashSet of visited nodes is acceptable but uses O(n) memory, and the candidate should say so.

14. What is the difference between static and dynamic languages?

Strong answer: use it as a follow up to question 5. Ask the candidate to compare Java with a language they’ve used, such as Python or JavaScript, in terms of when errors surface and how safe large refactors are.

Modern Java interview questions (Java 17 and later)

These questions show whether a candidate has kept up with the language.

  • What are records, and when would you use one instead of a class? Look for: immutable data carriers with generated equals, hashCode and toString; good for DTOs; a poor fit for entities that need mutable state.
  • What do sealed classes give you? Look for: a closed set of permitted subtypes, which lets the compiler check that a switch covers every case.
  • How does pattern matching for switch change your code? Look for: type patterns replace chains of instanceof checks and casts.
  • What are virtual threads, and when would you use them? Look for: lightweight threads, final in Java 21, that let thread per request code scale for I/O bound work. They don’t speed up CPU bound tasks.
  • How should Optional be used? Look for: as a return type for values that may be absent, and not as a field or parameter type.

Practical Java exercises

Conversation shows understanding; code shows ability. Pick one exercise sized to the role and give 30 to 45 minutes.

  • Build a small REST endpoint in Spring Boot that validates input and returns proper error codes.
  • Find and fix a race condition in a class that updates a shared counter from several threads.
  • Refactor a long method with nested conditionals into testable units and write unit tests with mocks.
  • Explain how you would handle a traffic spike on a service backed by a relational database, covering connection pooling and caching.

Glider’s coding simulations run exercises like these in full project environments, and live coding interviews let an interviewer and candidate work in a shared editor.

Behavioral questions for Java developers

  • Tell me about a production issue you debugged. What did you check first?
  • Describe a technical disagreement with a teammate and how it was resolved.
  • How do you decide when to upgrade a Java version or a major dependency?

Score these on structured thinking, ownership and evidence, using the same 1 to 4 scale.

Sample Java interview scorecard

AreaWeightScore (1 to 4)
Core Java and OOP25%
Collections and concurrency25%
Modern Java15%
Practical exercise25%
Communication and ownership10%

Agree on weights with the hiring manager before the first interview. Changing them after seeing candidates invites bias.

Run these interviews at scale

When you’re hiring several Java developers at once, the same questions can run through AI interviews that use fixed questions and evaluate answers against a rubric, with a recruiter reviewing every result. For other roles, see the Python developer interview questions guide or browse the interview questions library.

Frequently asked questions

What questions should I ask a Java developer in an interview?

Cover core Java (argument passing, exceptions, garbage collection), collections and concurrency (ConcurrentHashMap, threads, singletons), modern Java (records, virtual threads), one practical exercise and two behavioral questions.

How do I evaluate answers to Java developer interview questions?

Use a shared rubric: recall, explains, applies, judges tradeoffs. Score each answer from 1 to 4 and compare scores across interviewers before discussing the candidate.

What are the most common core Java interview questions?

Pass by value, checked versus runtime exceptions, HashMap versus ConcurrentHashMap, garbage collection, the Singleton pattern and lambda expressions.

Which Java version should interview questions cover?

The recent long term support releases (Java 17, 21 and 25), plus Java 8 concepts such as lambdas and streams that still appear in most codebases.

How long should a Java developer interview be?

Plan 45 to 60 minutes for the technical interview and 30 to 45 minutes for a practical exercise, after a short knowledge screen.

Should I test Java skills before the interview?

Yes. A short screen such as the Java skill test confirms fundamentals first, so the interview can focus on applied questions and the exercise.

What are good Java interview questions for experienced developers?

Ask about concurrency bugs they’ve fixed, garbage collection tuning, virtual threads, schema changes on live systems and design tradeoffs. Expect answers at level 4 on the rubric.

Architect Interview Questions: What to Ask Before You Hire

A strong architect portfolio tells you what got built. It rarely tells you what the candidate personally decided, what they gave up when the budget moved, or how they handled a contractor who said the detail couldn’t be built. Those are the things that decide whether a hire works out, and they only come out […]

Benefits Specialist Interview Questions: What to Ask and What Good Answers Sound Like

The best benefits specialist interview questions test four areas: compliance knowledge (COBRA, ERISA, ACA, HIPAA), program administration (open enrollment, vendors, HRIS), employee communication and judgment in sensitive situations. Ask for specific examples, then confirm the skills with a short job based skill test before the final round. A benefits specialist is the person employees call […]

Underwriter Interview Questions: What to Ask and What to Expect

Underwriters review applications, whether for insurance policies or loans, and decide how much risk a company should take on. Get a clear snapshot of how to screen the ideal candidate for your organization with this set of underwriter interview questions. The job of an underwriter is to review insurance or loan applications and carry out […]

chevron-down