0% found this document useful (0 votes)
102 views6 pages

Java Backend Developer Interview Questions

The document outlines a comprehensive list of interview questions for a Senior Java Backend Developer role, covering topics such as Java 8 features, Core Java concepts, Spring Boot, SQL, Microservices, Cloud & DevOps, and System Design. It includes questions on specific technologies like JPA, Hibernate, and AWS, as well as behavioral questions focused on leadership principles. Additionally, it highlights essential Java topics and frequently asked coding and theory questions relevant to the role.

Uploaded by

mkd0007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views6 pages

Java Backend Developer Interview Questions

The document outlines a comprehensive list of interview questions for a Senior Java Backend Developer role, covering topics such as Java 8 features, Core Java concepts, Spring Boot, SQL, Microservices, Cloud & DevOps, and System Design. It includes questions on specific technologies like JPA, Hibernate, and AWS, as well as behavioral questions focused on leadership principles. Additionally, it highlights essential Java topics and frequently asked coding and theory questions relevant to the role.

Uploaded by

mkd0007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java 8 and Project-Specific:

1. What are the new features added in Java 8?

2. What is Method Reference?

3. What are Default Methods?

4. Can you explain Intermediate Operations in Streams?

5. What is HTTP Status Code 204?

6. Can you explain the concept of Microservices in your project?

7. What is Logging, and which logging tool have you used?

8. Explain the Authentication Layer in your project.

9. How does JWT work, and what is its lifespan?

10. How does JWT works with Refresh Tokens?

11. Can you explain how you integrate 3rd-party data in your project?

Core Java:

1. What is Method Hiding?

2. Output of this - [Link](Double.MIN_VALUE > 0.0d);

3. If you add a null value to an empty Set, what will be the size of the Set?

4. What is Garbage Collection?

5. can you override static method in interface?

6. Internal working of HashMap and what is Get( ) method?

7. What is SOLID Principle?

Spring Boot:

1. @Lazy annotation

2. @Component annotation

3. What is Component Scanning?

4. How to handle exception in Spring Boot?

5. What is JPA?

6. Explain about Bean Scope?

7. @RequestParam

8. @RequestBody
9. What is path variable?

10. What is @GeneratedValue annotation?

SQL:

1. You have a user table with 50 records. Write a query to retrieve 20 records starting from the 5th
row. The result should include the user's first name and last name.

2. You have two tables. Write a query using INNER JOIN to retrieve data. You can use any example
data for this.

Java Backend Developer (3+ Yrs) :: Interview Questions Asked @ Amazon 🚀

♦️Core Java (OOPs, Collections, Concurrency)

1️⃣ Explain the internal working of ConcurrentHashMap in Java 8.

2️⃣ Difference between synchronized, ReentrantLock and ReadWriteLock.

3️⃣ How does Java handle memory leaks and how would you detect them?

4️⃣ How would you design a thread-safe singleton in Java?

5️⃣ Explain Java memory model (heap, stack, metaspace) and garbage collection tuning.

♦️Spring & Spring Boot

6️⃣ Explain how dependency injection works internally in Spring.

7️⃣ Difference between Spring Boot starters vs manual dependency management.

8️⃣ How do you implement idempotency in REST APIs?

9️⃣ How do you handle huge traffic in Spring Boot APIs? (connection pool, caching, async calls)

🔟 How would you secure AWS-hosted Spring Boot APIs with IAM roles / Cognito / JWT?

♦️JPA / Hibernate
1️⃣1️⃣ How would you optimize large batch inserts/updates in Hibernate?

1️⃣2️⃣ Explain difference between entity graphs and fetch joins for optimizing queries.

1️⃣3️⃣ How does 2nd level caching work in Hibernate and which providers have you used?

1️⃣4️⃣ How to handle optimistic locking failures gracefully?

1️⃣5️⃣ How do you tune SQL queries generated by JPA for performance?

♦️Microservices & Architecture

1️⃣6️⃣ Explain the difference between orchestration and choreography in microservices.

1️⃣7️⃣ How would you handle distributed transactions at scale? (Saga / Outbox pattern)

1️⃣8️⃣ Explain API throttling, rate limiting, and request bursting.

1️⃣9️⃣ How do you design a high-availability, fault-tolerant microservice?

2️⃣0️⃣ Describe an event-driven architecture you have implemented (Kafka, SQS, SNS, etc.).

♦️Cloud & DevOps Basics (AWS Focus)

2️⃣1️⃣ Explain difference between AWS EC2, ECS, EKS, and Lambda.

2️⃣2️⃣ How would you secure secrets and credentials in AWS? (Parameter Store, Secrets Manager)

2️⃣3️⃣ How do you achieve blue/green or canary deployments on AWS?

2️⃣4️⃣ How do you implement logging, tracing and monitoring (CloudWatch, X-Ray, ELK)?

2️⃣5️⃣ Difference between scaling using Auto Scaling Groups vs Kubernetes HPA.

♦️DSA & System Design (Amazon Special Focus)

2️⃣6️⃣ Design a rate limiter (like Amazon API Gateway throttling).

2️⃣7️⃣ Design a cache system with expiration and eviction policy.

2️⃣8️⃣ Given a massive log file stored in S3, find top 10 frequently accessed URLs efficiently.

2️⃣9️⃣ Given two sorted streams of data, merge them in real-time with minimal memory.
3️⃣0️⃣ Implement a thread-safe LRU cache in Java.

♦️Behavioral / Leadership Principles (Always Asked at Amazon)

3️⃣1️⃣ Tell me about a time you disagreed with your manager.

3️⃣2️⃣ Describe a situation where you delivered results under tight deadlines.

3️⃣3️⃣ Tell me about a time when you improved a process or system.

3️⃣4️⃣ Describe how you handle failure in a project.

3️⃣5️⃣ Tell me about a time when you influenced a team without authority

5 Must-Know Core Java Topics (My Learning)

1)Java 8 features including Streams, Lambdas, Functional Interfaces, Optional and Method
References

2)OOP principles such as Encapsulation, Inheritance, Abstraction and Polymorphism

3)Java Collections Framework including internal working and concurrency collections

4)Multithreading and Concurrency including synchronization, locks and ExecutorService

5)Modern Java features like Records, GC updates, var keyword, modules and sealed classes

Frequently Asked Interview Questions (Based on My Interviews)

Coding

1)Stream API problems using grouping, filtering and mapping

2)String manipulation problems

3)Array based problems such as sorting, searching and sliding window

Theory

1)Abstract class vs Interface

2)When to choose interface or abstract class

3)Method overriding vs creating new methods

4)Local and global exception handling


5)How Optional class works

6)Functional Interface, Lambda and Method Reference

7)Thread creation methods and Executor Service

8)What Record class is and where it is used

9)Recent Garbage Collector improvements including G1 and ZGC

👤 Role: Senior Java Backend Developer – Spring Boot & Microservices

🟦 Core Java

1. What are virtual threads in Java 21 and how do they differ from traditional threads?

2. How does record improve DTO handling in Java?

3. Explain the difference between [Link](), orElse(), and orElseThrow().

4. How does ConcurrentHashMap achieve thread safety internally?

5. What are switch expressions and how are they different from switch statements?

6. Explain the Fork/Join framework and its advantages.

7. How does pattern matching for instanceof simplify Java code?

8. How do you implement immutability in Java classes?

9. What are the benefits of using streams and functional programming in Java?

10. How does Java handle memory management for unreachable objects?

🟦 Spring + Spring Boot

11. How does Spring Boot auto-configuration determine which beans to create?

12. What is the difference between @Component, @Service, and @Repository?

13. How do you configure global exception handling using @ControllerAdvice?

14. How do you secure REST APIs using Spring Security and JWT?

15. What are Spring Profiles and how do they help manage environments?

16. How does Spring Boot integrate with external configuration servers?

17. How do you implement scheduling in Spring Boot?


18. Explain how Spring Boot Actuator helps monitor applications.

19. How do you implement rate limiting and throttling in Spring Boot?

20. How do you manage dependency injection and circular dependencies in Spring?

🟦 Microservices

21. How do you implement service discovery in microservices architecture?

22. What is the difference between synchronous REST calls and asynchronous messaging?

23. How do you ensure fault tolerance using Circuit Breaker or Retry patterns?

24. How do you handle versioning of microservices APIs?

🟦 Coding Questions

[Link] a Java 8 stream code to group employees by department and get the highest salary per
department.

Common questions

Powered by AI

Java 8 introduced several key features that significantly enhance the Java programming experience. These include Lambda Expressions which simplify the implementation of single-method interfaces by using expressions instead of full classes. Method References provide a way to refer to methods directly and treat them as First-Class Citizens, similar to Lambda expressions. The Stream API offers a way to process sequences of elements (like collections) in a functional-style, which simplifies parallelized data processing and operations like filtering, mapping, and reducing. Optional class aims to handle null values better by providing a container object which may or may not contain a non-null value. The addition of Default Methods allows methods with a body in interfaces, enabling extension of interfaces without breaking existing implementations. These features promote cleaner, more functional programming and improve code readability and maintainability .

In microservices architecture, orchestration refers to a centralized approach where a single service (orchestrator) controls and manages the interaction between services. It has complete visibility of the workflow, making it easier to monitor and manage. However, it can become a bottleneck or single point of failure. Choreography, on the other hand, is a decentralized approach where each service reacts independently to the events it receives, leading to a more reactive system. It allows for greater scalability and flexibility as there is no central point of control, but it also can result in more complex service interactions and harder-to-debug systems due to the distributed nature .

Circuit Breaker and Retry patterns are crucial in ensuring fault tolerance in microservice architectures. The Circuit Breaker pattern prevents a service from trying to execute an action that is likely to fail, avoiding system overloads which could make a bad situation worse. When failures are detected, the circuit opens, failing fast to allow time for the system to recover. Once it stabilizes, half-open trials are tested until it closes fully. The Retry pattern complements this by automatically attempting to re-invoke the failed operation, with strategies to back off either exponentially or based on fixed intervals. Implementations typically use libraries like Resilience4j or Spring Cloud Circuit Breaker for integration .

Internally, a HashMap in Java uses an array of nodes, known as buckets, to store entries. Each entry includes a key-value pair, a hash of the key, and a reference to the next node (to handle collisions). The map indexes entries using the hash of the key, which determines the bucket index. The Get() method calculates the hash of the key and retrieves the node in the appropriate bucket. If the key matches directly with a node, the value is returned; otherwise, a traversal of the linked list or a tree (in cases of high collision) occurs until the correct node is found. The use of good hashing functions and balanced trees of nodes ensures efficient retrieval times of O(1) in the average case .

Spring Boot handles dependency injection through the use of the Spring IoC container, which manages the lifecycle and configuration of application objects. It uses annotations like @Autowired to wire dependencies automatically. However, circular dependencies, where two or more beans depend on each other, can pose challenges. They can lead to a cycle that Spring cannot resolve unless the dependencies are mutable or managed with interfaces or separate bean initializations. Spring provides ways to resolve these via the @Lazy annotation or by refactoring the code to remove the circular dependency .

The Fork/Join framework in Java is designed to improve multi-threaded performance by allowing tasks to be broken into smaller sub-tasks through a divide-and-conquer approach. It utilizes a work-stealing algorithm where idle threads can ‘steal’ tasks from busy threads, maximizing CPU utilization. The framework is highly efficient in leveraging multi-core processors because it splits tasks into independent subtasks, processes them in parallel, and merges the results, facilitating enhanced performance for computing-intensive operations. Some key advantages include efficient decomposition of tasks for recursive algorithms and improved execution time for large-scale data processing tasks .

Implementing immutability in Java classes is beneficial as immutable objects are inherently thread-safe, simplifying concurrent programming by avoiding synchronization issues. Immutability can be achieved by declaring all fields as final, not providing setter methods, and ensuring that mutable objects are returned in an unmodifiable way or are deeply copied before use. This reduces bug risks as states cannot be modified after creation, leading to more reliable and maintainable code. More importantly, immutable objects can be easily shared across threads without additional synchronization .

Java's virtual threads, introduced in recent updates, differ from traditional threads as they are lightweight and managed by the Java runtime rather than the operating system. This allows millions of virtual threads to be created and managed concurrently with minimal resource overhead. They enhance performance by decoupling the number of threads from the number of available processor cores, enabling more efficient utilization of server resources, particularly in I/O-bound applications. Virtual threads reduce context-switching costs and allow for more scalable concurrent processing by mapping many virtual threads to fewer native threads .

ConcurrentHashMap achieves thread safety by using a segmented lock approach which divides the map into multiple segments each protected by its own lock. This allows multiple threads to read and write concurrently to different segments, reducing contention and improving performance compared to a single synchronized map with a global lock. Additionally, in Java 8, it employs a non-blocking algorithm for reads and additional lock-free algorithms for updates, minimizing lock contention even further. This structure makes ConcurrentHashMap highly efficient for concurrent access patterns commonly found in parallel computations .

Pattern matching for instanceof simplifies Java code by streamlining the process of checking an object type and casting its type. Previously, a separate cast was needed after an instanceof check, but pattern matching combines them into a single operation. This reduces boilerplate code, enhances readability, and reduces the possibility of errors. It introduces a new type-safe pattern where if the instanceof condition is true, a variable of the checked type is automatically available in scope, which simplifies verbose casting and error handling code .

You might also like