Fujitsu Java Developer Interview Experience: 23 Advanced Questions to Prepare For
Preparing for a Java developer interview at a product-based company or a large technology organization? Advanced interviews often go beyond Core Java and Spring Boot fundamentals. They test your understanding of JVM internals, concurrency, system design, database performance, distributed transactions, and real-world problem-solving.
Here are 23 advanced Java interview questions covering topics worth revising for experienced backend developers and senior engineers.
1. Core Java and Collections
- How does
ConcurrentHashMapwork internally?
Explain how hashing, collision handling, and concurrent updates work. How does it differ from HashMap and Hashtable, and how does it support concurrent access without locking the entire map for every operation?
- What happens if you modify an object’s field used by
equals()andhashCode()after inserting it into aHashMap?
Explain how changing a key’s hash-related state can make an existing entry difficult to retrieve, even when the same object reference is used. Why should map keys ideally be immutable?
3. How does the JVM load, link, initialize, and unload classes?
Discuss class loading, verification, preparation, resolution, initialization, and garbage-collection-related class unloading. How can classloader leaks occur in applications that use application servers, plugins, or dynamically deployed modules?
- How does
IdentityHashMapdiffer fromHashtable?
Explain how IdentityHashMap compares keys using reference identity (==) rather than logical equality through equals(). Is it thread-safe? How does it differ from Hashtable in terms of synchronization and intended use cases?
- Why should mutable objects generally not be used as
HashMapkeys?
Discuss how changes to fields involved in equals() and hashCode() can break expected lookup behavior. Explain why immutable key objects are generally safer.
6. Design a custom collection that supports average O(1) lookup while preserving insertion order.
Describe a possible implementation using a hash-based lookup structure and a doubly linked list, similar to the design principles behind LinkedHashMap. Explain insertion, deletion, lookup, and how the data structures work together.
2. Modern Java Features and Concurrency
7. Compare Java records, ordinary classes, and data classes in other languages. When might a Java record be unsuitable for a domain model?
Explain records as concise carriers of data with generated methods such as accessors, equals(), hashCode(), and toString(). Discuss their shallow immutability and limitations when a model requires mutable state, inheritance from a class, or complex identity-based entity behavior.
8. How do sealed classes, pattern matching, and exhaustive switch expressions work together?
Explain how sealed classes restrict which types can extend or implement a type, and how pattern matching simplifies type-specific logic. Discuss how exhaustive switch expressions help the compiler identify missing cases when the relevant type hierarchy is known.
9. What are virtual threads and structured concurrency? What limitations should developers consider?
Explain how virtual threads make thread-per-task programming practical for many blocking workloads. Discuss their suitability for I/O-bound applications, their limitations for CPU-intensive work, and the need to consider synchronization, native calls, and resource constraints.
Structured concurrency provides a model for treating related concurrent tasks as a single unit with coordinated lifetimes and failure handling. Its APIs and maturity depend on the Java version, so distinguish preview or evolving features from finalized functionality.
10. Explain the Java Memory Model and the happens-before relationship.
Describe how the Java Memory Model defines the visibility and ordering of memory operations across threads. Explain how synchronization, volatile variables, and thread-start or join relationships establish happens-before guarantees.
- Why is
volatile int count; count++not thread-safe?
Although volatile provides visibility and ordering guarantees for individual accesses, count++ is a compound read-modify-write operation. Multiple threads can read the same value and overwrite each other’s updates. Discuss when AtomicInteger, synchronization, or locks are appropriate.
12. Two threads update the same bank account simultaneously. How would you design a thread-safe solution?
Explain how to prevent lost updates and maintain account invariants. Discuss synchronization or locking for in-memory state, database transactions and optimistic or pessimistic locking for persisted balances, and why financial operations require appropriate consistency guarantees.
3. Spring Boot and Backend Engineering
13. How does Spring Boot auto-configuration work internally?
Explain how Spring Boot uses conditional configuration, classpath detection, application properties, and bean registration to configure components automatically. How can developers override default behavior or exclude an auto-configuration class?
- Why might
@Transactionalfail when one method calls another method within the same class?
Discuss Spring’s proxy-based transaction management. In the common proxy-based setup, self-invocation bypasses the proxy, so the internal method’s transactional annotation may not trigger the expected transaction behavior. Explain possible design alternatives and how transaction propagation affects execution.
15. How would you design an idempotent payment API that prevents duplicate transactions during retries?
Discuss idempotency keys, request validation, persistent storage of request outcomes, database constraints, and transaction boundaries. Explain how the system should handle repeated requests, concurrent retries, and failures that occur after a payment provider has processed a transaction.
4. Performance, Databases, and Microservices
16. An API’s average response time is 150 ms, but P99 latency exceeds 3 seconds. How would you investigate?
Explain why averages can hide slow requests affecting a small percentage of users. Investigate distributed traces, endpoint-level latency, database queries, thread pools, connection pools, garbage collection, network calls, and traffic spikes. Use metrics and traces to identify the bottleneck before optimizing.
17. How would you diagnose and fix the N+1 query problem in Hibernate?
Explain how an initial query can be followed by additional queries for related entities. Discuss fetch joins, entity graphs, batch fetching, and DTO projections. Explain how to verify the problem using SQL logs, query metrics, and integration tests while avoiding unnecessarily large result sets.
18. HikariCP reports connection timeouts after 30 seconds. How would you identify the root cause?
Investigate connection-pool metrics, active and idle connections, connection acquisition time, slow queries, long-running transactions, database limits, and connection leaks. Explain why simply increasing the pool size may worsen database contention rather than solve the underlying issue.
19. When should a monolithic application be split into microservices, and when is a modular monolith preferable?
Discuss independent deployment, team ownership, scaling requirements, domain boundaries, and operational maturity. Compare these benefits with the additional complexity of network communication, observability, distributed transactions, and service management.
20. A payment succeeds, but inventory reservation fails. How would you implement the Saga pattern?
Explain how a distributed business transaction can be split into local transactions coordinated through orchestration or choreography. Discuss compensating actions, retries, timeouts, idempotency, and recovery when a step fails after an earlier step has completed.
21. A Kafka consumer updates the database successfully but crashes before committing its offset. How would you prevent duplicate business operations?
Explain why the message may be delivered again after restart. Discuss idempotent consumers, unique event identifiers, database uniqueness constraints, and transaction boundaries. Where appropriate, explain the transactional outbox pattern and why Kafka transactions alone do not automatically make arbitrary external database operations exactly-once.
22. Explain at-most-once, at-least-once, and exactly-once processing. What limitations exist across databases and external systems?
- At-most-once: A message may be lost, but it is not processed more than once under the defined delivery semantics.
- At-least-once: Messages are retried until acknowledged, so duplicates are possible.
- Exactly-once: Processing effects are guaranteed once within a clearly defined scope and set of supported transactional boundaries.
Discuss how Kafka transactions, idempotent processing, database transactions, and external API behavior affect the end-to-end guarantee. Be precise about what the system actually guarantees.
5. Data Structures and Coding
23. Find the longest subarray with sum K when negative numbers are allowed. Explain the optimal algorithm.
A sliding-window approach generally does not work when negative numbers are allowed because the running sum is no longer monotonic.
A standard solution uses prefix sums and a hash map:
- Maintain the running prefix sum while traversing the array.
- For each position, check whether the prefix sum minus
Khas appeared before. - If it has, calculate the candidate subarray length.
- Store the earliest index for each prefix sum so the longest possible subarray can be found.
- Track the maximum length throughout the traversal.
The algorithm runs in expected O(n) time and uses O(n) additional space.

