🚀 Java & Spring Boot Interview Questions Every Developer Should Know Whether you're preparing for interviews or brushing up your fundamentals, here’s a curated list of important questions covering Core Java, Spring Boot, JPA, and Microservices 👇 🔹 𝐂𝐨𝐫𝐞 𝐉𝐚𝐯𝐚 & 𝐂𝐨𝐧𝐜𝐮𝐫𝐫𝐞𝐧𝐜𝐲 1. What is CompletableFuture and when do we use it? 2. Difference between Future and CompletableFuture 3. Internal working of HashMap 4. HashMap vs ConcurrentHashMap 5. How does the Java Memory Model (JMM) work? 6. What is the volatile keyword? 🔹 𝐒𝐩𝐫𝐢𝐧𝐠 𝐁𝐨𝐨𝐭 & 𝐁𝐚𝐜𝐤𝐞𝐧𝐝 𝐂𝐨𝐧𝐜𝐞𝐩𝐭𝐬 7. How does Spring Boot Auto-Configuration work? 8. How do we handle transactions in Spring Boot? 9. What are Propagation & Isolation levels in transaction management? 10. What is Dependency Injection? 🔹 𝐉𝐏𝐀 & 𝐇𝐢𝐛𝐞𝐫𝐧𝐚𝐭𝐞 11. Application is slow due to JPA – how do you improve performance? 12. What is Dirty Checking? 13. Difference between JPA and Hibernate 14. How to implement DTO Projection in JPA? (Write a query) 🔹 𝐌𝐢𝐜𝐫𝐨𝐬𝐞𝐫𝐯𝐢𝐜𝐞𝐬 𝐀𝐫𝐜𝐡𝐢𝐭𝐞𝐜𝐭𝐮𝐫𝐞 15. Two microservices sharing the same database – is it a good approach? 16. Two microservices updating the same row simultaneously – how do you handle it? 17. If one microservice goes down, how does it impact the system? How do you handle it? 18. How do you improve overall application performance? 💻 𝐏𝐫𝐨𝐠𝐫𝐚𝐦𝐦𝐢𝐧𝐠 𝐐𝐮𝐞𝐬𝐭𝐢𝐨𝐧𝐬 ✔️ Find all permutations of a string "abc" ✔️ Check if a string is balanced: "{[()]}" 𝐀𝐥𝐥 𝐓𝐡𝐞 𝐁𝐞𝐬𝐭✌ #Java #SpringBoot #Microservices #JPA #BackendDevelopment #InterviewPreparation #SoftwareEngineering
Java Spring Boot Interview Questions and Answers
More Relevant Posts
-
If you’re preparing for a Java Spring Boot interview, these are the questions you MUST know inside-out: Spring Boot Core 1. What is Spring Boot Auto-configuration? How does it work internally, and how do you customize it using @ConditionalOnProperty or @AutoConfigureBefore? 2. Difference between @Component, @Service, @Repository — Are they functionally different or just semantic? 3. Explain the Bean Lifecycle — @PostConstruct, @PreDestroy, InitializingBean, DisposableBean — when to use which? 4. How does Spring Boot Actuator help in production monitoring? Explain /health, /metrics, and custom endpoints. 5. How do you build custom Spring Boot starters? Walk through the folder structure and auto-configuration setup. Spring Security & Authentication 1. How does Spring Security Filter Chain work internally? Explain the flow from request to authentication. 2. What is the OAuth2 + JWT authentication flow? How do you implement stateless authentication in microservices? 3. How do you implement role-based access control (RBAC)? @PreAuthorize vs @Secured vs manual checking. Microservices & Distributed Systems 1. Explain the Circuit Breaker pattern — How does Resilience4j help prevent cascading failures? 2. What is idempotency in REST APIs? How do you ensure POST/PUT requests don’t create duplicate records? 3. How do you implement distributed tracing? Sleuth + Zipkin or OpenTelemetry — trace IDs across services. 4 What is the Saga pattern? How do you handle distributed transactions without 2PC? JPA / Hibernate / Database 1. What is the N+1 problem? How do you solve it using @EntityGraph or JOIN FETCH? 2. Difference between lazy and eager loading — When does LazyInitializationException occur? 3. Explain optimistic vs pessimistic locking — @Version annotation and use cases. For structured learning and interview prep, you can book an appointment with me. #java #springboot #coding #engineering #interviews
To view or add a comment, sign in
-
🚀 Spring Boot Interview Questions (Part 1) After sharing Core Java & Java 8 questions, here are Spring Boot questions that were frequently asked in my interviews 👇 🔹 Core Spring Concepts Explain Bean Lifecycle What is Bean Scope? What is the default scope? 🔹 Scope-Based Scenario If a class has singleton scope and it has a reference of prototype bean, how does it behave? @Scope("singleton") class A { B b; } @Scope("prototype") class B { } 👉 Follow-up: How can we ensure it behaves like prototype instead of singleton? 🔹 Important Comparisons Java Singleton vs Spring Singleton Scope Difference between @Primary and @Qualifier 🔹 Transaction Management Transactions, Propagation, and Isolation 👉 Scenario-based questions on propagation 🔹 Annotations & Config What annotations have you used? Explain them @RequestBody is used for JSON → Java object 👉 What if you want to support another data format? @ConfigurationProperties vs @Value @ConditionalOnProperty How to create beans based on environment or condition 🔹 Spring Security Spring Security basics JWT Authentication vs Authorization 🔹 Web Layer @PathVariable vs @RequestParam 🔹 Build Tool Maven Lifecycle 🔹 Spring Data JPA What is @Repository? interface StudentRepo extends JpaRepository<Student, Integer> { } 👉 Why Integer is used instead of int? 🔹 Configuration Files If same values are defined in both .properties and .yml, which one is loaded first? 🔹 Database How to use multiple databases in a single Spring Boot application? 🔹 APIs What are Spring Boot Starters? SOAP API vs REST API Advantages and disadvantages of REST API Difference between @RestController and @Controller 🔹 Dependency Injection What is Dependency Injection? Types of Dependency Injection Which one do you prefer and why? 🔹 Profiles & AOP Profiles in Spring Boot Spring AOP Filter vs Interceptor 🔹 Miscellaneous How to upload file and save in DB @Async vs CompletableFuture 👉 Follow for Part 2 (Advanced Spring Boot + Microservices Interview Questions) 🔁 Repost so others can benefit too #SpringBoot #Java #Backend #InterviewPreparation #Microservices
To view or add a comment, sign in
-
⚡ map vs flatMap in Java (Stream API) Definition: map() → Transforms each element 1:1 flatMap() → Transforms and flattens nested structures 🤔 Why use? 1. map() - When output is a single value per input - Simple transformations 2. flatMap() - When each element produces multiple values (collections/streams) - Avoid nested structures like List<List<T>> 💻 Example List<List<Integer>> list = Arrays.asList( Arrays.asList(1, 2), Arrays.asList(3, 4), Arrays.asList(5, 6) ); // map() → creates nested structure List<Stream<Integer>> mapResult = list.stream() .map(inner -> inner.stream()) .collect(Collectors.toList()); // flatMap() → flattens into single stream List<Integer> flatMapResult = list.stream() .flatMap(inner -> inner.stream()) .collect(Collectors.toList()); 🔄 Flow map() List<List> → Stream<List> → Stream<Stream> flatMap() List<List> → Stream<List> → Stream 🧠 Rule of Thumb 👉 If your transformation returns a single value → use map() 👉 If it returns a collection/stream → use flatMap() 👉 If you are preparing for Java backend interviews, connect & follow - I share short, practical backend concepts regularly. #Java #Backend #Streams #Java8 #CodingInterview #InterviewPrep #SoftwareEngineering
To view or add a comment, sign in
-
-
📘 Follow me for daily Java, Spring Boot, SQL & System Design MCQs to crack MNC interviews 🚀 ✅ Correct Answer: D) 7 int[] arr = {1, 2, 3}; arr[1] = arr[1] + 5; System.out.println(arr[1]); 🧠 Explanation (Array index concept in Java) Arrays in Java are 0-indexed. Initial array values by index: arr[0] = 1 arr[1] = 2 arr[2] = 3 Step-by-step execution arr[1] initially is 2. Statement: arr[1] = arr[1] + 5; 2 + 5 = 7 Now array becomes: {1, 7, 3} System.out.println(arr[1]); Prints the updated value → 7 💡 Key Points Java arrays start from index 0. You can update array elements using their index. #Java #SpringBoot #FullStackDeveloper
To view or add a comment, sign in
-
-
Java Backend Developer – 2nd Round Interview These 20 questions separate good developers from great ones. 1. How does the G1 Garbage Collector work? What are regions, and how does it decide what to collect? 2. What is a memory leak in Java? Walk through how you’d detect and fix one in production. 3. How does ReentrantLock differ from synchronized? When would you prefer one over the other? 4. Explain happens-before in Java Memory Model. Why does it matter in multithreaded code? 5. How does Spring’s @Transactional handle rollback internally? What are common pitfalls? 6. What is the difference between REQUIRED, REQUIRES_NEW and NESTED propagation in transactions? 7. How would you implement distributed locking across microservices? 8. How does Hibernate’s first-level vs second-level cache work? When does it hurt you? 9. Explain the N+1 problem in JPA. How do you detect and fix it? 10. How would you design an idempotent REST API? Why does it matter? 11. How does database connection pooling work? How do you tune HikariCP for high throughput? 12. What is eventual consistency? How would you handle it in a microservices architecture? 13. How do you implement optimistic vs pessimistic locking? When would you use each? 14. How would you design a rate limiter for a public API? 15. What is the Saga pattern? How does it compare to 2PC for distributed transactions? 16. How would you secure inter-service communication in a microservices setup? 17. How does Kafka ensure message ordering and exactly-once delivery? 18. How would you design a system that processes 1 million requests per day without downtime? 19. How do you do zero-downtime deployment for a Spring Boot service running in Kubernetes? 20. Your service’s p99 latency spiked from 80ms to 2s overnight. Walk me through your debugging process. Preparing for interviews? Start revising these today 𝗜’𝘃𝗲 𝗽𝗿𝗲𝗽𝗮𝗿𝗲𝗱 𝗶𝗻 𝗗𝗲𝗽𝘁𝗵 𝗝𝗮𝘃𝗮 𝗦𝗽𝗿𝗶𝗻𝗴𝗯𝗼𝗼𝘁 𝗯𝗮𝗰𝗸𝗲𝗻𝗱 𝗚𝘂𝗶𝗱𝗲, 𝟏𝟬𝟬𝟬+ 𝗽𝗲𝗼𝗽𝗹𝗲 𝗮𝗿𝗲 𝗮𝗹𝗿𝗲𝗮𝗱𝘆 𝘂𝘀𝗶𝗻𝗴 𝗶𝘁. 𝗚𝗲𝘁 𝘁𝗵𝗲 𝗴𝘂𝗶𝗱𝗲 𝗵𝗲𝗿𝗲: https://lnkd.in/dfhsJKMj keep learning, keep sharing ! #java #backend #javaresources
To view or add a comment, sign in
-
Java Bug Fix Interview Question - Retry Utility with Silent Failures Scenario You are building a retry utility in Java for a Spring Boot microservice. The utility accepts a Supplier<T> (lambda) and retries the lambda up to maxAttempts if it throws an exception. A junior engineer writes a client code (attached image) Observed Behavior When processItem() fails: - Error is logged - Retry does not happen (only 1 attempt) - Why are retries not happening? - Can you write a test that demonstrate this failing behavior? Also fix the original code. Detailed solution with explanation: https://lnkd.in/ev6G4zA5 For more subscribe and join 6500+ Java & Spring Boot engineers: https://lnkd.in/gwiRqWBV #java #spring #springboot
To view or add a comment, sign in
-
-
🚀 Java Backend Interview Series – Day 11 Spring is a must for backend roles 👇 🌱 Spring Core (Fundamentals): 1️⃣ What is IoC (Inversion of Control)? 2️⃣ What is Dependency Injection (DI)? Types? 3️⃣ Difference between IoC and DI? 4️⃣ What is Spring Bean? 5️⃣ Bean lifecycle in Spring? 6️⃣ What is @Component, @Service, @Repository? 7️⃣ What is @Autowired and how does it work? 8️⃣ @Primary vs @Qualifier? 9️⃣ Singleton bean in Spring vs Singleton in Java? 🔟 Are Spring beans thread-safe? 💡 Spring questions = real project understanding 📌 and Save this for revision 👇 Comment “NEXT” for such questions #Java #Spring #SpringBoot #BackendDevelopment #InterviewPrep #Developers #Coding
To view or add a comment, sign in
-
My recent interview experience related to Java, Spring Boot, REST APIs, Microservices, and Databases 👇 🔹 Core Java What is the difference between String, StringBuilder, and StringBuffer? How does HashMap work internally? Difference between ConcurrentHashMap and HashMap? What is the Java Memory Model (JMM)? Explain multithreading and synchronization What is the difference between ExecutorService and Thread? What is Optional class and why is it used? 🔹 Spring Boot What is Spring Boot and how is it different from Spring? What are starters in Spring Boot? Explain @SpringBootApplication What is dependency injection (DI)? Difference between @Component, @Service, @Repository, @Controller? What is Spring Boot Auto Configuration? How does application.properties/yml work? 🔹 REST APIs What is a RESTful API? Difference between PUT vs PATCH What are idempotent APIs? What is HTTP status code usage? How do you handle exception handling globally? What is @RestControllerAdvice? How to implement pagination and sorting? 🔹 Database (SQL + NoSQL) Difference between SQL vs NoSQL What is indexing and how does it improve performance? What is normalization vs denormalization? Explain ACID properties What is transaction management in Spring? Difference between JPA and Hibernate What is lazy vs eager loading? How to solve N+1 query problem? #Java #SpringBoot #Microservices #RESTAPI #BackendDevelopment #FullStackDeveloper #Hibernate #JPA #SQL #SystemDesign #SoftwareEngineering #TechInterview #InterviewPreparation #DevelopersOfLinkedIn #Coding #Programming #JavaDeveloper
To view or add a comment, sign in
-
🧩 Optional in Java What is Optional? A wrapper to represent a value that may be absent, helps avoid null and makes intent clear. ✅ Why use it? 1. Prevents NullPointerException 2. Forces explicit handling of missing values 3. Cleaner and more readable APIs ⚖️ Correct vs Wrong Usage 1️⃣ Return Types ❌ User findUser(int id); // may return null ✅ Optional<User> findUser(int id); 2️⃣ Fields & Params ❌ Optional<String> name; // field void process(Optional<String>); // param 👉 Adds confusion + not intended use ✅ String name; void process(String data); 3️⃣ Accessing Value ❌ user.get(); // unsafe ✅ user.orElse(defaultUser); user.orElseThrow(); 4️⃣ Best Use (Chaining 💡) return Optional.ofNullable(user) .map(User::getAddress) .map(Address::getCity) .orElse("Unknown"); 🧠 Rule of Thumb 👉 Use Optional only for return types 👉 Avoid in fields, DTOs, method params 👉 Prefer map/flatMap over null checks 👉 If you are preparing for Java backend interviews, connect & follow - I share short, practical backend concepts regularly. #Java #SpringBoot #Backend #CleanCode #CodingTips #Developers #InterviewPrep #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Spring Boot Annotations Every Java Developer Must Know If you're working in Java backend development, mastering Spring Boot annotations is non-negotiable. These annotations are the backbone of how Spring Boot handles: ✅ Dependency Injection ✅ REST APIs ✅ Database & JPA ✅ Validation ✅ Exception Handling ✅ Security ✅ Bean Configuration A strong understanding of annotations helps you write cleaner code, debug faster, and explain concepts confidently in interviews. Some annotations every developer should be comfortable with: 🔹 @SpringBootApplication 🔹 @RestController 🔹 @Autowired 🔹 @Service 🔹 @Repository 🔹 @Transactional 🔹 @RequestBody 🔹 @PathVariable 🔹 @ExceptionHandler 🔹 @ControllerAdvice 💡 Interview tip: Don’t just memorize annotations — understand where Spring internally uses them and why. For example: 👉 @SpringBootApplication = combination of @Configuration + @EnableAutoConfiguration + @ComponentScan That single answer alone creates strong interview impact. Which Spring Boot annotation do you use most often in your project? #Java #SpringBoot #BackendDevelopment #JavaDeveloper #Microservices #Programming #SoftwareEngineering #CodingInterview #TechLearning #DeveloperCommunity
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development