Leanpub Header

Skip to main content

The Java and Spring Boot Interview Compendium

Interview Questions and Answers for Java and Spring Boot Developers

The Java and Spring Boot Interview Compendium

A practical backend interview reference covering modern Java and Spring Boot development (1497 manuscript pages).

Minimum price

$19.99

$29.99

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
About

About

About the Book

The Java and Spring Boot Interview Compendium is a question-and-answer reference for backend developers preparing for Java and Spring Boot interviews, and for anyone who wants to explain the platform rather than only use it. It contains more than five hundred questions across fifteen chapters, and each answer goes past the definition to the mechanism behind it and the trade-off it carries, so that readers can reason about a question they have not seen before instead of reciting a memorized reply. Almost every answer is paired with a Java code listing.

The material is roughly two-thirds Java and one-third Spring. It begins with how the language evolved from Java 8 to Java 21, then works through fundamentals and object-oriented programming, collections and data structures, generics, lambdas, and streams, exception handling and annotations, concurrency, JVM internals and performance tuning, design patterns, and object-oriented design. The second half turns to Spring: the IoC container, dependency injection, and proxies; Spring Boot and REST APIs; persistence with JPA and Hibernate; testing with JUnit 5, Mockito, and Spring Boot test slices; and Spring Security, architecture, and deployment. The two halves are connected throughout, so the Spring chapters keep returning to the Java mechanisms they are built on.

The book is practical rather than tutorial. In the Java chapters the listings are, with few exceptions, complete programs with their own main method, and in the Spring chapters they are focused excerpts written against the real Spring, JPA, JUnit, and Spring Security APIs. Chapters mix core concepts with production scenarios such as diagnosing a memory or CPU problem, migrating a Java 8 and Spring Boot 2 service to Java 21 and Spring Boot 3, designing idempotent APIs, and deploying without downtime, and nearly every chapter ends with a section of coding challenges. Along the way the book builds a hash map, an LRU cache, a rate limiter, a connection pool, and a circuit breaker by hand.

Readers come away able to explain how equality, immutability, generics, the Java Memory Model, and garbage collection actually behave, to choose between collections and concurrency tools and state what each choice costs, and to use thread dumps, heap dumps, and GC logs to narrow down a problem. On the Spring side they should be able to describe what the container, its proxies, and auto-configuration do on their behalf, design REST APIs and persistence layers with pitfalls such as N+1 queries and lost updates in view, test at the right level, and discuss security, architecture, resilience, and deployment in terms of trade-offs.

It is written for developers who already work in Java, from mid-level engineers preparing for senior interview loops to Spring developers refreshing the platform beneath the framework, and it is not a first tutorial. The chapters can be read in order or consulted by topic, which makes the book useful both as a study plan and as a reference before a technical interview.

Author

About the Author

Yohan Rodriguez

Yohan is a Senior Full-Stack Software Engineer with extensive experience delivering scalable, end-to-end software solutions across web, enterprise, and cloud-based environments. He specializes in architecting robust platforms, modernizing legacy systems, driving cloud transformation efforts, and building integration-heavy applications that support critical business workflows. He is recognized for translating complex requirements into reliable, maintainable, and high-value solutions across industries such as insurance, cybersecurity, and professional services.

Known for combining strong technical execution with a practical business mindset, he has contributed to projects from concept and design through production delivery and long-term support. His experience includes collaborating with cross-functional teams, improving development workflows, solving complex technical challenges, and helping organizations deliver dependable software products that adapt to changing business needs. He brings a balanced approach to engineering that values quality, efficiency, and continuous improvement.

Contents

Table of Contents

  • Preface i
  • 1 Java Version History and Evolution 1
    • 1.1 Key Java Versions 1
    • 1.2 Migration and Compatibility 10
    • 1.3 Important Feature Deep Dives 15
    • 1.4 Advanced Version Topics 24
    • 1.5 Interview Scenarios and Comparisons 53
    • 1.6 Practical Java Evolution 79
  • 2 Java Fundamentals 92
    • 2.1 Java Basics 92
    • 2.2 Type System and Conversions 101
    • 2.3 Strings and Immutability 103
    • 2.4 Enums and Constants 107
    • 2.5 Object Class Methods 111
    • 2.6 Advanced Fundamentals 115
    • 2.7 Memory and Performance Fundamentals 128
    • 2.8 Interview Scenario Questions 141
    • 2.9 Debugging and Scenario Questions 156
    • 2.10 Coding Challenge Questions 175
  • 3 Object-Oriented Programming in Java 186
    • 3.1 Core OOP Concepts 186
    • 3.2 Object Class and Contracts 195
    • 3.3 Interfaces and Abstract Design 199
    • 3.4 Inheritance and Polymorphism 206
    • 3.5 Inner and Nested Classes 215
    • 3.6 Advanced OOP 222
    • 3.7 Design Decision Questions 252
    • 3.8 OOP Coding Challenges 277
  • 4 Collections and Data Structures 291
    • 4.1 Core Collections 291
    • 4.2 Advanced Collections 299
    • 4.3 Concurrent Collections 302
    • 4.4 Immutable and Utility Collections 308
    • 4.5 Choosing the Right Collection 315
    • 4.6 Performance and Internals 325
    • 4.7 Scenario-Based Questions 332
    • 4.8 Data Structure Implementation Questions 344
    • 4.9 Collections Coding Challenges 365
  • 5 Generics, Streams, and Lambdas 377
    • 5.1 Generics 377
    • 5.2 Lambda Expressions and Functional Interfaces 383
    • 5.3 Streams 387
    • 5.4 Advanced Generics 392
    • 5.5 Advanced Stream Operations 397
    • 5.6 Optional 409
    • 5.7 Functional Programming Patterns 415
    • 5.8 Stream Performance and Pitfalls 417
    • 5.9 Advanced Generics Scenarios 429
    • 5.10 Interview Coding Challenges 440
    • 5.11 Stream Coding Challenges 454
  • 6 Exception Handling and Annotations 465
    • 6.1 Exception Handling 465
    • 6.2 Annotations 475
    • 6.3 Advanced Exception Handling 482
    • 6.4 Advanced Annotations 490
    • 6.5 Exception Design Patterns 501
    • 6.6 Annotation Internals and Patterns 513
    • 6.7 Exception Scenarios 528
    • 6.8 Exception Coding Challenges 547
  • 7 Concurrency and Multithreading 560
    • 7.1 Thread Basics 560
    • 7.2 Synchronization and Locks 566
    • 7.3 Concurrency Utilities 573
    • 7.4 Thread Safety and Atomic Operations 579
    • 7.5 Concurrent Data Structures 589
    • 7.6 Advanced Concurrency 597
    • 7.7 Concurrency Patterns 606
    • 7.8 Debugging and Diagnostics 616
    • 7.9 Modern Concurrency 627
    • 7.10 Concurrency Interview Scenarios 637
    • 7.11 Concurrency Coding Challenges 658
  • 8 JVM, Memory Management, and Performance 670
    • 8.1 JVM Architecture 670
    • 8.2 Memory and Performance 677
    • 8.3 Advanced JVM Internals 686
    • 8.4 Diagnostics and Monitoring 699
    • 8.5 Advanced JVM Topics 713
    • 8.6 Performance Scenarios 735
    • 8.7 JVM Coding Challenges 758
  • 9 Design Patterns 772
    • 9.1 Creational Patterns 772
    • 9.2 Structural Patterns 778
    • 9.3 Behavioral Patterns 782
    • 9.4 Additional Patterns 788
    • 9.5 Enterprise and Spring Patterns 811
    • 9.6 Pattern Application Scenarios 836
    • 9.7 Pattern Coding Challenges 855
  • 10 OOP Design and Best Practices 869
    • 10.1 SOLID Principles 869
    • 10.2 Clean Code and Refactoring 877
    • 10.3 Advanced Design 883
    • 10.4 Design Principles in Practice 897
    • 10.5 Real-World Design Scenarios 922
    • 10.6 Design Coding Challenges 952
  • 11 Spring Fundamentals and Dependency Injection 966
    • 11.1 Inversion of Control and Dependency Injection 966
    • 11.2 Bean Configuration and Lifecycle 972
    • 11.3 Configuration and Profiles 979
    • 11.4 Advanced Spring Concepts 982
    • 11.5 Spring Context and Environment 992
    • 11.6 Spring Internals 1004
    • 11.7 Spring Configuration Patterns 1014
    • 11.8 Spring Debugging and Scenarios 1025
    • 11.9 Spring Coding Challenges 1044
  • 12 Spring Boot and REST APIs 1058
    • 12.1 Spring Boot Fundamentals 1058
    • 12.2 Building REST APIs 1063
    • 12.3 API Best Practices 1072
    • 12.4 Advanced REST API Topics 1075
    • 12.5 Spring Boot Internals 1085
    • 12.6 Advanced REST Patterns 1096
    • 12.7 Production Readiness 1107
    • 12.8 REST API Scenario Questions 1119
    • 12.9 REST Coding Challenges 1139
  • 13 JPA, Hibernate, and Persistence 1154
    • 13.1 JPA Fundamentals 1154
    • 13.2 Queries and Transactions 1165
    • 13.3 Spring Data JPA 1173
    • 13.4 Advanced Persistence 1175
    • 13.5 Performance Optimization 1200
    • 13.6 Advanced JPA 1213
    • 13.7 Persistence Scenarios 1226
    • 13.8 Persistence Coding Challenges 1247
  • 14 Testing and Quality 1264
    • 14.1 Unit Testing with JUnit 5 1264
    • 14.2 Mocking with Mockito 1274
    • 14.3 Spring Boot Testing 1286
    • 14.4 Advanced Testing 1296
    • 14.5 Testing Strategies 1307
    • 14.6 Advanced Testing Techniques 1319
    • 14.7 Testing Scenarios 1331
    • 14.8 Testing Coding Challenges 1354
  • 15 Security, Architecture, and Deployment 1371
    • 15.1 Spring Security Fundamentals 1371
    • 15.2 JWT and Token-Based Security 1381
    • 15.3 Security Best Practices 1390
    • 15.4 Application Architecture 1395
    • 15.5 Deployment and DevOps 1409
    • 15.6 Advanced Security 1418
    • 15.7 System Design and Scalability 1430
    • 15.8 Architecture Decision Questions 1442
    • 15.9 Architecture Coding Challenges 1465
  • Conclusion 1485

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub