🚀 Java Backend Developer (3–6 Yrs) Java Interview Questions I Faced Recently Over the past 15 days, I attended 4–5 interviews, and I came across some really interesting Java-related questions. Maybe this will help you guys 😊 1. Is it possible for a Spring Boot project to contain more than one main method? If yes, which one will execute when we run the project? 2. When we perform operations using Hibernate, how does it work internally? Explain the process. 3. What do you know about AtomicInteger? 4. What are SOLID principles? 5. If we already have a login API and want to add login via OTP, CAPTCHA, or username/password without creating a new API and without modifying the existing one directly, how can we implement this in Spring Boot? 6. What do you know about REST API? 7. What is the difference between @Controller and @RestController? 8. What are the different bean scopes in Spring? 9. What are the types of Dependency Injection in Spring? 10. When should we use the @Transactional annotation in Hibernate, and how can we manage transactions without using it? 11. What is a Bean in Spring, and what is its lifecycle? 12. If an API calls another API sequentially (one-by-one, where the next waits for the previous to complete), what is this model called in Spring Boot? 13. Can you give a real-world example where you implemented SOLID principles in your project? 14. What is Microservices Architecture, and why should we use it instead of Monolithic Architecture? 15. What are the different ways to communicate between microservices? 16. Apart from Feign Client, RestTemplate, and WebClient, what other tools/technologies can be used for communication? (e.g., Apache Kafka, Redis Cache) 17. Design an API with proper layering (Controller, Service, Repository) and implement Global Exception Handling. 18. What annotations have you used in your Spring Boot projects? Give examples. 19. How can we optimize database queries or transactions to improve performance? 20. If a request goes through API Gateway → Controller → Service → Database and is taking too much time, how would you optimize and improve performance? 21. You mentioned Apache Kafka in your resume — what do you know about it? 22. In Hibernate, when using @OneToMany mapping, where do you place the annotation (in which class/variable)? Explain how it works. 23. If APIs execute concurrently (parallel execution), what is this model called? 24. What is Spring Security? What do you know about the Spring Filter Chain? 25. What is the difference between JWT and Session? 26. What is the Singleton Design Pattern? 27. Where is the Singleton Design Pattern used in multithreading? 28. What are the features of Java 21?
Here are 50-character-or-fewer title options for the LinkedIn post: 1. Java Interview Questions I Faced Recently 2. Java Developer Interview Prep 3. Java Interview Questions and Answers 4. Java Backend Developer Interview Prep 5. Java Spring Boot Interview Questions
More Relevant Posts
-
What Does a Java Full Stack Developer Interview Typically Cover? What a Java Full Stack Developer is expected to do: Back-End: Java, Spring Boot, REST APIs, databases (SQL/NoSQL) Front-End: HTML, CSS, JavaScript, and frameworks like React, Angular, or Vue Tools & DevOps: Git, Docker, Jenkins, Maven/Gradle, CI/CD Soft Skills: Problem-solving, communication, teamwork Key Tips to Crack the Interview 1. Master the Basic Concepts of Java Concentrates on: OOP principles- Inheritance, Encapsulation, Polymorphism, and Abstraction Collections Framework Multithreading and Concurrency Exceptions Handling Java 8+ features- Streams, Lambdas, Optional, Functional Interfaces. 2. Understand With Backend Frameworks (Spring, Spring Boot) Build REST APIs Using Annotation like @RestController, @Service, @Autowired Connect to databases using JPA/Hibernate Handle Exception globally Secure the API with Spring Security. 3. Be Good at Front End Development Key skills: HTML, CSS, and JavaScript(ES6+) Basics of React.js or Angular State Management, (Redux, useState, useEffect) Consume REST APIs Responsive design using Bootstrap or Material UI 4. Refresh Your Knowledge of Databases Be prepared to: Write optimized SQL queries. Normalize database schemas. Work with PostgreSQL/MySQL/MongoDB. Use JPA/Hibernate to perform CRUD operations. 5. Refresh Basic System Design REST vs. SOAP Microservices vs. Monolithic Scalability, Load Balancing, and Caching API Gateway and Service Registry Database Partitioning and Replication Top Interview Questions by Category Core Java What are List, Set, and Map in Java? How does garbage collection work in Java? Explain synchronized versus volatile versus thread-safe collections. What are the differences between HashMap and ConcurrentHashMap? What are the benefits of using Streams and Lambdas for a cleaner, more beautiful way of Java programming? Spring Boot What are the differences between Spring and Spring Boots How does Spring handle Dependency Injection? What is the use of @RestController, @RequestMapping, @PathVariable, and @RequestParam? How do you globally handle exceptions in Spring Boot? How to perform JWT-based authentication in Spring Boot? Frontend(React/Angular) What is the props and state difference in React? How do React Hooks such as useEffect and useState work? What are React lifecycle methods? Database Write a SQL query to find the second-highest salary in a table. What is implemented by Join and the reason for using it? What do you mean by ACID properties in transactions? How does JPA manage relationships such as OneToMany, ManyToMany? How to avoid a Hibernate N+1 problem? DevOps & Tools How do you deploy a Spring Boot app using Docker? What is the role of CI/CD in the full-stack development life cycle? How are you using Git for version control in a team setting? What's the difference between Maven and Gradle? How do you keep track of logs in production? Learn More at Softronix!
To view or add a comment, sign in
-
-
🚀 Java Backend Developer (3–6 Yrs) Java Backend Developer – 1st Round Interview These 20 questions are being asked RIGHT NOW. 1. How does HashMap work internally? Explain buckets, hashing & resizing. 2. What is the difference between HashMap and ConcurrentHashMap? 3. How does JVM memory structure work? (Heap, Stack, Metaspace) 4. What causes OutOfMemoryError in production? How would you debug it? 5. How do you make a class thread-safe? Give a real scenario. 6. Explain the complete lifecycle of a Spring Bean. 7. How does Dependency Injection work internally in Spring? 8. What actually happens when you use @Transactional? 9. Difference between @Component, @Service and @Repository? 10. How would you handle global exception handling in Spring Boot? 11. What is lazy vs eager loading in JPA? When can it cause performance issues? 12. How do you handle concurrent updates to the same database row? 13. Explain ACID properties with a banking transaction example. 14. How do you optimize a slow SQL query? 15. How would you design pagination & sorting in a REST API? 16. How does JWT authentication work step by step? 17. If your API is slow under load, how would you identify the bottleneck? 18. REST vs Messaging (Kafka), when would you choose which? 19. How would you Dockerize a Spring Boot application? 20. If two microservices fail during communication, how do you handle fault tolerance? Preparing for interviews? Start revising these today
To view or add a comment, sign in
-
Preparing for a Senior Java Developer interview at Wells Fargo 💼 Sharing a curated list of questions that helped me revise deeply across core Java, system design, and real-world problem solving. Hope this helps others preparing for similar roles 👇 🔹 Core Java & JVM What are the key differences between Java 17 and Java 21? How does JVM memory management work? Explain Heap vs Stack vs Metaspace. What are strong, weak, soft, and phantom references? How does garbage collection work? Which GC is best for low-latency systems? Difference between Comparable and Comparator with use cases. 🔹 Multithreading & Concurrency Difference between synchronized, ReentrantLock, and ReadWriteLock. Explain thread safety. How do you design a thread-safe class? What is volatile and how is it different from synchronization? Explain producer-consumer problem with real-world use case. How does CompletableFuture improve async programming? 🔹 Collections & Data Structures Internal working of HashMap (Java 8+ changes). Difference between HashMap, ConcurrentHashMap, and Hashtable. How does LRU Cache work? Implement it. When would you use a TreeMap over a HashMap? 🔹 Spring Boot & Microservices How does Spring Boot auto-configuration work internally? Difference between @Component, @Service, and @Repository. How does Spring handle transactions? Explain propagation levels. How do you handle inter-service communication (REST vs Kafka)? How do you implement resilience (Retry, Circuit Breaker)? 🔹 System Design (Important for Senior Roles) Design a scalable notification system. How would you design a payment processing system? How do you ensure idempotency in distributed systems? How do you handle millions of concurrent users? Explain API gateway and service discovery. 🔹 Database & JPA Difference between optimistic and pessimistic locking. N+1 query problem and how to solve it. How does Hibernate caching work (L1 vs L2)? Write a query to fetch top N records efficiently. Indexing strategies for large datasets. 🔹 Kafka & Event-Driven Systems How does Kafka ensure durability and fault tolerance? What happens if a consumer fails after consuming a message? How do you avoid duplicate message processing? Explain partitioning and consumer groups. 🔹 Coding / Problem Solving LRU Cache Valid Parentheses Two Sum / Variants Sliding Window problems Producer-Consumer implementation 🔹 Behavioral & Leadership Tell me about a system you designed end-to-end. How do you handle production failures? How do you mentor junior developers? A time you disagreed with architecture decisions. 💡 Tip: For senior roles, interviewers focus more on decision-making, trade-offs, and real-world experience rather than just theory. If you're preparing for Wells Fargo or similar product-based companies, focus on depth over breadth. Let’s grow together 🚀 #Java #SeniorDeveloper #WellsFargo #SystemDesign #Microservices #InterviewPreparation #BackendDevelopment #TechCareers
To view or add a comment, sign in
-
To become expert in java, as much as learn is always low , here are few java questions whose ans good to know if your favorite language is JAVA
Writes to 10k+ | Senior Associate Technology @ Publicis Sapient | Ex-Amdocs | Ex-TCS | Distributed Systems | Java | Springboot | Microservices | Kafka | Rest API | AWS EKS | Openshift | SQL | NoSQL | CI/CD
Preparing for a Senior Java Developer interview at Wells Fargo 💼 Sharing a curated list of questions that helped me revise deeply across core Java, system design, and real-world problem solving. Hope this helps others preparing for similar roles 👇 🔹 Core Java & JVM What are the key differences between Java 17 and Java 21? How does JVM memory management work? Explain Heap vs Stack vs Metaspace. What are strong, weak, soft, and phantom references? How does garbage collection work? Which GC is best for low-latency systems? Difference between Comparable and Comparator with use cases. 🔹 Multithreading & Concurrency Difference between synchronized, ReentrantLock, and ReadWriteLock. Explain thread safety. How do you design a thread-safe class? What is volatile and how is it different from synchronization? Explain producer-consumer problem with real-world use case. How does CompletableFuture improve async programming? 🔹 Collections & Data Structures Internal working of HashMap (Java 8+ changes). Difference between HashMap, ConcurrentHashMap, and Hashtable. How does LRU Cache work? Implement it. When would you use a TreeMap over a HashMap? 🔹 Spring Boot & Microservices How does Spring Boot auto-configuration work internally? Difference between @Component, @Service, and @Repository. How does Spring handle transactions? Explain propagation levels. How do you handle inter-service communication (REST vs Kafka)? How do you implement resilience (Retry, Circuit Breaker)? 🔹 System Design (Important for Senior Roles) Design a scalable notification system. How would you design a payment processing system? How do you ensure idempotency in distributed systems? How do you handle millions of concurrent users? Explain API gateway and service discovery. 🔹 Database & JPA Difference between optimistic and pessimistic locking. N+1 query problem and how to solve it. How does Hibernate caching work (L1 vs L2)? Write a query to fetch top N records efficiently. Indexing strategies for large datasets. 🔹 Kafka & Event-Driven Systems How does Kafka ensure durability and fault tolerance? What happens if a consumer fails after consuming a message? How do you avoid duplicate message processing? Explain partitioning and consumer groups. 🔹 Coding / Problem Solving LRU Cache Valid Parentheses Two Sum / Variants Sliding Window problems Producer-Consumer implementation 🔹 Behavioral & Leadership Tell me about a system you designed end-to-end. How do you handle production failures? How do you mentor junior developers? A time you disagreed with architecture decisions. 💡 Tip: For senior roles, interviewers focus more on decision-making, trade-offs, and real-world experience rather than just theory. If you're preparing for Wells Fargo or similar product-based companies, focus on depth over breadth. Let’s grow together 🚀 #Java #SeniorDeveloper #WellsFargo #SystemDesign #Microservices #InterviewPreparation #BackendDevelopment #TechCareers
To view or add a comment, sign in
-
🚀 NEC #Interview Prep – Angular + Java Full Stack Preparing for a Full Stack role? Here are Top 45 Interview Questions you must know 👇 #Frontend – Angular How does Angular change detection work? Default vs OnPush strategy? How does lazy loading improve performance? How do you pass data between components? @Input vs @Output – difference? What are lifecycle hooks with real use cases? RxJS vs Promise? switchMap vs mergeMap? How do you optimize Angular apps? How do you structure a large Angular project? #Java Core (Must Strong) 11. Why is String immutable in Java? 12. What is OOP? Explain all principles. 13. Encapsulation vs Abstraction? 14. Inheritance vs Composition? 15. What is Polymorphism (compile vs runtime)? 16. What is the difference between == and equals()? 17. What is the difference between stack and heap memory? 18. What are wrapper classes? 19. What is Exception Handling? 20. Checked vs Unchecked exceptions? #Collections & Data Structures 21. ArrayList vs LinkedList? 22. HashMap vs Hashtable? 23. How HashMap works internally? 24. What is hashing? 25. Difference between Set and List? #Spring Boot (Core + Advanced) 26. What is Spring Boot? 27. What are starter dependencies? 28. What is @SpringBootApplication? 29. What is @RestController? 30. What is @Autowired? 31. What is @Transactional? 32. What is Spring Boot Actuator? 33. How does dependency injection work in Spring? 34. What is Bean lifecycle? 35. How do you handle exceptions in Spring Boot? #Database – MySQL Basics 36. What is normalization? 37. Primary key vs Foreign key? 38. What is indexing? 39. Difference between INNER JOIN and LEFT JOIN? 40. How do you optimize SQL queries? 🏗️ System Design / Architecture 41. How do you design a scalable full stack system? 42. How does frontend communicate with backend? 43. How do you structure packages in Java? 44. How do you handle large data flow between components/services? 45. How do you ensure performance and scalability? #Pro Tip: Always explain with real project examples (Angular + Spring Boot) 🔥 Save this post & start preparing now! #Angular #Java #SpringBoot #FullStack #TechLead #NEC #InterviewPrep #SystemDesign #YT- https://lnkd.in/gS9cCzWS #IG- https://lnkd.in/gFJTMatR #GH- https://lnkd.in/er5iG6DJ #GR- https://lnkd.in/g2ycKJgw
To view or add a comment, sign in
-
-
#Java Is Not As Simple As We Think Today, I interviewed an experienced Java developer. The candidate was doing great — solid fundamentals, clear communication, and a good grasp of concepts. I was impressed. Then I decided to turn up the difficulty a notch with a few tricky questions. To my surprise, the candidate struggled — not because of a lack of skill, but because these are the kind of edge cases that slip out of daily practice. I still moved the candidate to the next round because overall knowledge and problem-solving ability matter more than gotcha questions. But it made me reflect on something important. Why do experienced developers miss these? As we grow into system design, architecture, and leadership roles, we naturally move away from low-level nuances. The basics become “assumed knowledge” that we rarely revisit — and that’s where the gaps quietly form. Here are the three questions I asked: Q1: Does finally ALWAYS execute? We’re taught that finally block always runs. But does it really? try { System.out.println("Inside try"); System.exit(0); } finally { System.out.println("Finally executed"); } Finally executed” never prints. System.exit() shuts down the JVM before finally gets a chance to run. The rule has exceptions. Q2: Does substring() always create a new String? We know runtime String operations create new objects on the heap. But what does this print? String str = "java"; String s = str.substring(0); System.out.println(str == s); // true or false? It prints true. When substring(0) covers the entire string, Java is smart enough to return the same reference instead of creating a new object. The optimization many developers don’t expect. Q3: Are two Integer objects with the same value always equal with ==? Integer a = 127; Integer b = 127; System.out.println(a == b); // true Integer x = 128; Integer y = 128; System.out.println(x == y); // false Surprised? Java caches Integer objects in the range -128 to 127. Within this range, == works because both variables point to the same cached object. Beyond 127, new objects are created on the heap, and == compares references — not values. This is why .equals() should always be your default for object comparison. The takeaway: Java is not a simple language. Even professionals with years of experience get tripped up by its subtle behaviors and exceptions to the rules. The language rewards curiosity and continuous learning — no matter how senior you are. Keep revisiting the fundamentals. They have more depth than you remember. #Java #SoftwareEngineering #Interviews #CoreJava #ContinuousLearning #JavaDeveloper #JavaIsNotEasy
To view or add a comment, sign in
-
Spring & Spring Boot Annotations Every Java Developer Should Know If you're preparing for interviews or working on real-time projects, mastering these annotations is a must! 💡 @Primary-When multiple beans of the same type exist, this one gets autowired by default. @Order - Controls the order in which components are applied or loaded (e.g., filters or interceptors). @Scope-Defines bean scope: singleton (default), prototype, request, session, etc. @Qualifier-Helps resolve conflict when multiple beans of the same type are available by specifying which one to inject. Dependency Injection Annotations @Autowired-Automatically injects a dependency by type. Can be applied to constructors, fields, or setters. @Resource - JSR-250 standard. Injects by name (first), then by type. @Inject-JSR-330 standard. Functions like @Autowired, but without Spring-specific options like required=false. @Required-Ensures that a property must be set in Spring config. Throws error if not Initialized (now deprecated in favor of constructor injection). Spring Boot Annotations @SpringBootApplication-Combines @Configuration, @EnableAutoConfiguration, and @Component Scan in a single annotation to bootstrap a Spring Boot app easily. @EnableAutoConfiguration - Tells Spring Boot to auto-configure your application based on the dependencies present on the classpath. @Configuration Properties - Binds external configuration (like from application.properties) to a POJO and validates them using JSR-303/JSR-380. @Conditional0nClass-Loads a bean or configuration only if a specified class is available in the classpath. @Conditional0nMissingClass - Opposite of @ConditionalOnClass; activates if the class is not present. @Conditional0nBean - Loads configuration or beans only if a certain bean exists. @Conditional0nMissingBean-Loads the bean only if the specified bean is not present in the context. @Conditional0nProperty-Activates beans/config based on a property's presence and value. @EnableConfiguration Properties - Enables support for @Configuration Properties-annotated beans. @ConstructorBinding-Indicates that configuration properties should be bound using the constructor instead of setters. #Java #SpringBoot #Microservices #BackendDeveloper #InterviewPreparation #JavaDeveloper #Coding #TechCareers
To view or add a comment, sign in
-
Java Project Ideas for Every Developer. Beginner Java Projects -> Basic Banking System (CLI) -> Student Grade Calculator -> Multiplication Table Generator -> Palindrome Checker -> Prime Number Generator -> Random Password Generator -> To-Do List (CLI) -> Contact Book (CLI) -> Random Quote Generator -> Simple Interest Calculator -> Unit Converter (Length, Weight) -> Basic File Reader/Writer -> Word Count Tool -> Email Slicer Tool -> Random Name Generator -> Random Username Generator -> Basic Encryption Tool (Caesar Cipher) -> Basic Decryption Tool -> Random Sentence Generator -> Random Math Quiz -> Random Story Generator -> Simple Reminder App (CLI) -> Basic Calendar CLI -> Random Lottery Picker -> Random Team Generator -> Simple CSV Reader -> JSON Parser Tool -> Random Data Generator Intermediate Java Projects -> GUI Calculator (Swing/JavaFX) -> GUI To-Do List App -> GUI Contact Manager -> GUI Email Client (SMTP/IMAP) -> REST API using Spring Boot -> CRUD API with Spring Boot + MySQL -> Authentication System (JWT + Spring Security) -> Blog Backend with Spring Boot -> E-commerce Backend (basic) -> File Upload Service -> URL Shortener API -> API Rate Limiter -> Logging System with Log4j -> Caching System with Redis -> Multithreading File Processor -> Producer-Consumer System -> Web Scraper with Jsoup -> Chat Server with WebSockets -> Notification System -> Email Service Backend -> Scheduling System (Quartz) -> Search Engine (basic) Advanced Java Projects -> Full Stack E-commerce System (Spring Boot + React) -> Microservices Architecture System (Spring Cloud) -> Distributed System with Service Discovery (Eureka) -> API Gateway with Load Balancing -> High-scale Chat Application (WebSockets + Kafka) -> Real-time Data Processing System -> Event-driven System with Kafka -> Distributed Job Queue System -> Scalable File Storage System -> Cloud-native Java Application (Kubernetes) -> Serverless Java Backend (AWS Lambda) -> Identity & Access Management System (IAM) -> OAuth2 Authorization Server -> Payment Gateway System -> Fraud Detection System -> AI-powered Recommendation Engine -> Real-time Analytics Dashboard Backend -> Data Pipeline System (ETL with Java) -> Distributed Logging System (ELK + Java) -> Observability Platform -> Multi-region Deployment System -> High-performance Cache System (Redis Cluster) -> Distributed Locking System -> Blockchain-based Java Backend -> Secure Messaging System -> Multiplayer Game Server Backend -> No-code Backend Engine -> DevOps Automation Tool -> CI/CD System (Java-based) -> Container Orchestration Tool -> Cloud Cost Optimization Tool -> Security Monitoring System -> Threat Detection System 𝗜’𝘃𝗲 𝗽𝗿𝗲𝗽𝗮𝗿𝗲𝗱 𝗶𝗻 𝗗𝗲𝗽𝘁𝗵 𝗝𝗮𝘃𝗮 𝗦𝗽𝗿𝗶𝗻𝗴𝗯𝗼𝗼𝘁 𝗯𝗮𝗰𝗸𝗲𝗻𝗱 𝗚𝘂𝗶𝗱𝗲, 𝟏𝟬𝟬𝟬+ 𝗽𝗲𝗼𝗽𝗹𝗲 𝗮𝗿𝗲 𝗮𝗹𝗿𝗲𝗮𝗱𝘆 𝘂𝘀𝗶𝗻𝗴 𝗶𝘁. 𝗚𝗲𝘁 𝘁𝗵𝗲 𝗴𝘂𝗶𝗱𝗲 𝗵𝗲𝗿𝗲: https://lnkd.in/dfhsJKMj #java #backend #javaresources
To view or add a comment, sign in
-
📘 Follow me for daily Java, Spring Boot, SQL & System Design MCQs to crack MNC interviews 🚀 🧠 Java Interview MCQ — Day 6 Topic: Java Collections Q1. Output of List with duplicates List<String> list = new ArrayList<>(); list.add("A"); list.add("B"); list.add("A"); System.out.println(list.size()); Answer: C) 3 Why: ArrayList allows duplicate elements and preserves insertion order. You added 3 items, so size is 3. Q2. Which collection does NOT allow duplicate elements? Answer: C) HashSet Why: HashSet follows Set rules. Set never allows duplicate values. Q3. Method used to sort a List in Java Answer: B) Collections.sort() Why: Collections.sort() sorts a List in natural order or using a Comparator. Q4. Default initial capacity of ArrayList Answer: C) 10 Why: When ArrayList resizes for the first time, it creates capacity of 10. Q5. Which interface is implemented by ArrayList? Answer: C) List Why: ArrayList implements the List interface. Q6. What happens if you add null into HashSet? Answer: B) Only one null allowed Why: HashSet allows a single null value because duplicates are not allowed. Q7. Which class maintains insertion order? Answer: C) LinkedHashSet Why: LinkedHashSet maintains insertion order using a linked list and hash table. Q8. Which of the following is NOT synchronized? Answer: C) ArrayList Why: ArrayList is not thread-safe. Vector, Hashtable, and Stack are synchronized. Q9. Which method removes an element by index in ArrayList? Answer: B) remove() Why: remove(int index) method removes element by index. Q10. Which collection is best for key–value pairs? Answer: C) Map Why: Map is designed for key and value mapping like HashMap, TreeMap, LinkedHashMap. ✅ Concept Summary List → allows duplicates, ordered Set → no duplicates Map → key/value pairs ArrayList → not synchronized, allows duplicates HashSet → one null, no duplicates LinkedHashSet → maintains insertion order #Java #SpringBoot #FullStackDeveloper
To view or add a comment, sign in
-
-
One of the toughest questions in every senior Java interview: “How does @Transactional actually work in Spring Boot?” Most candidates stop at: ➡️ “It manages database transactions automatically.” That’s not wrong — but it’s far from enough. Here’s what really happens under the hood When you use @Transactional, Spring doesn’t modify your class directly. It creates a proxy using Spring AOP. So when your method is called: 👉 You’re not calling your code directly 👉 You’re calling the proxy first That proxy: 1️⃣ Intercepts the method call 2️⃣ Delegates to a TransactionInterceptor 3️⃣ Uses a PlatformTransactionManager 4️⃣ Starts the transaction (via ThreadLocal context) 5️⃣ Executes your method 6️⃣ Commits or rolls back based on outcome 💡 Your business code never manages transactions — Spring does it transparently. --- ### ⚠️ But here’s where things break in production 1. Self Invocation (Silent Failure) Calling a @Transactional method within the same class bypasses the proxy. ❌ No transaction is applied ✅ Fix: Call via another bean or through Spring context --- 2. Checked Exceptions Don’t Rollback By default, only RuntimeException triggers rollback. ❌ Checked exception → transaction commits ✅ Fix: @Transactional(rollbackFor = Exception.class) --- 3. Wrong Propagation = Data Inconsistency - REQUIRED → joins existing (safe) - REQUIRES_NEW → starts new (can cause partial commits) - NESTED → savepoints (partial rollback) ❌ Payment fails but order is committed 👉 Classic production issue --- ### 🧠 What senior engineers understand ✔️ Transaction context is maintained using ThreadLocal ✔️ Transactions should wrap business use cases, not just DB calls ✔️ Isolation levels matter for concurrency ✔️ Lazy loading fails outside transaction boundaries ✔️ readOnly = true improves performance --- ### 🎯 The answer that gets the offer @Transactional works via Spring AOP proxies. The proxy intercepts method calls and delegates transaction management to a TransactionManager. However, it can silently fail due to proxy bypass (self-invocation), default rollback rules, and incorrect propagation settings — leading to real production issues if not handled carefully. The gap between knowing @Transactional and understanding it deeply 👉 is the gap between getting shortlisted and getting the offer. #Java #SpringBoot #BackendEngineering #SystemDesign #TechInterviews #S
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