🚀 Java Backend Interview Series – Question #75 Q75. What are Bean Scopes in Spring Framework? When working with Spring Framework / Spring Boot, one important concept that often comes up in interviews is: 👉 Bean Scope It defines: 👉 How many instances of a bean are created and how long they live Let’s break it down 👇 🔹 1️⃣ What is a Bean Scope? In Spring, a bean is an object managed by the Spring IoC container. Bean scope determines: ✔ Lifecycle of the bean ✔ Visibility of the bean ✔ Number of instances created 🔹 2️⃣ Types of Bean Scopes 🔸 Singleton (Default Scope) @Component @Scope("singleton") class MyService {} 📌 Characteristics: ✔ Only one instance per Spring container ✔ Shared across the entire application 👉 Most commonly used in backend systems 🔸 Prototype @Scope("prototype") class MyService {} 📌 Characteristics: ✔ New instance created every time requested ✔ Not managed after creation 👉 Use case: When you need independent objects 🔸 Request Scope (Web) @Scope("request") class MyService {} 📌 Characteristics: ✔ One instance per HTTP request 👉 Use case: Request-specific data 🔸 Session Scope (Web) @Scope("session") class MyService {} 📌 Characteristics: ✔ One instance per HTTP session 👉 Use case: User-specific data 🔸 Application Scope @Scope("application") class MyService {} 📌 Characteristics: ✔ One instance per ServletContext 🔹 3️⃣ Key Differences ScopeInstances CreatedUse CaseSingletonOneShared servicesPrototypeMultipleIndependent objectsRequestPer requestWeb request dataSessionPer sessionUser session dataApplicationPer appGlobal data🔹 4️⃣ Real-World Backend Insight ✔ Most beans in Spring Boot are Singleton ✔ Prototype is used for stateful objects ✔ Request/Session scopes are used in web applications 🔹 5️⃣ Important Concept 👉 Singleton in Spring ≠ Singleton Design Pattern Spring creates one instance per container, not per JVM. 🎯 Interview Tip A tricky question: 👉 “Is Spring Singleton thread-safe?” Answer: ❌ No by default ✔ It depends on how the bean is implemented 💬 Follow-up Interview Question What happens if a Prototype bean is injected into a Singleton bean? #Java #SpringBoot #SpringFramework #BeanScope #JavaDeveloper #BackendDevelopment #CodingInterview #TechInterview #SoftwareEngineering #Microservices #Programming #DeveloperCommunity #SystemDesign #CleanCode #IoC
Spring Bean Scopes Explained: Singleton, Prototype, Request, Session, Application
More Relevant Posts
-
🚀 Java Backend Interview Series – Question #78 Q78. What is the difference between @RestController and @Controller in Spring? If you work with Spring Boot, you’ve definitely used: 👉 @Controller 👉 @RestController But in interviews, a very common question is: 👉 “When should you use @RestController vs @Controller?” Let’s break it down clearly 👇 🔹 1️⃣ @Controller @Controller is used in Spring MVC for building web applications (UI-based). Example: @Controller public class HomeController { @GetMapping("/home") public String home() { return "home"; // returns view name } } 📌 Behavior: ✔ Returns view name (HTML/JSP) ✔ Used with Thymeleaf / JSP / UI rendering 🔹 2️⃣ @RestController @RestController is used for building REST APIs. It is a combination of: @Controller + @ResponseBody Example: @RestController public class UserController { @GetMapping("/users") public List<String> getUsers() { return List.of("A", "B", "C"); } } 📌 Behavior: ✔ Returns JSON/XML data ✔ No view rendering 🔹 3️⃣ Key Differences Feature@Controller@RestControllerPurposeWeb MVC (UI)REST APIsReturn TypeView (HTML/JSP)JSON/XML@ResponseBodyRequiredIncluded by defaultUse CaseFrontend renderingBackend APIs🔹 4️⃣ When Should You Use Each? ✔ Use @Controller when: Building web pages Returning views/templates ✔ Use @RestController when: Building REST APIs Returning data (JSON/XML) 🔹 5️⃣ Real-World Backend Insight In modern applications: ✔ Most backend services use @RestController ✔ @Controller is mainly used in traditional MVC apps 👉 In microservices architecture, @RestController is dominant 🔹 6️⃣ Important Detail Even in @Controller, you can return JSON: @ResponseBody public String data() { return "Hello"; } But @RestController makes it default and cleaner. 🎯 Interview Tip A tricky question: 👉 “Can we use @Controller for REST APIs?” Answer: ✔ Yes, by adding @ResponseBody ❗ But @RestController is preferred 💬 Follow-up Interview Question What is the difference between @RequestBody and @ResponseBody? #Java #SpringBoot #RestController #Controller #RESTAPI #JavaDeveloper #BackendDevelopment #CodingInterview #TechInterview #SoftwareEngineering #Microservices #Programming #CleanCode #SpringFramework #APIDesign
To view or add a comment, sign in
-
-
🚀 Spring Boot Annotations Every Backend Developer (4+ YOE) Must Know If you're preparing for Java backend interviews or working on real-world projects, mastering Spring Boot annotations is a game changer. Here are some of the most important ones with practical usage 👇 🔹 @SpringBootApplication Combination of @Configuration + @EnableAutoConfiguration + @ComponentScan 👉 Entry point of your Spring Boot application 🔹 @RestController Combines @Controller + @ResponseBody 👉 Used to create RESTful APIs (returns JSON directly) 🔹 @RequestMapping / @GetMapping / @PostMapping 👉 Used to map HTTP requests to handler methods Example: @GetMapping("/users") → fetch all users 🔹 @Autowired 👉 Used for Dependency Injection (DI) Spring automatically injects required beans 🔹 @Component / @Service / @Repository 👉 Used to define Spring-managed beans @Component → generic @Service → business logic @Repository → database layer 🔹 @Entity 👉 Marks a class as a JPA entity (mapped to DB table) 🔹 @Table 👉 Customize table name in database 🔹 @Id & @GeneratedValue 👉 Used for primary key and auto-generation strategy 🔹 @Transactional 👉 Manages transaction (commit/rollback) 💡 Important for DB consistency 🔹 @Configuration 👉 Used to define custom bean configurations 🔹 @Bean 👉 Method-level annotation to create beans manually 🔹 @Value 👉 Inject values from application.properties 🔹 @Qualifier 👉 Used when multiple beans of same type exist 💡 Pro Tip (Interview Insight): Most interviewers don’t just ask definitions — they expect real use cases + flow understanding Example: 👉 How @Transactional behaves in nested calls 👉 Difference between @Component vs @Service 🔥 Real-Life Example: In a microservices project, we used: @RestController → expose APIs @Service → business logic @Repository → DB operations @Transactional → ensure rollback in failure scenarios 📌 Common Interview Questions: ✔ Difference between @Component, @Service, @Repository ✔ How @Autowired works internally ✔ Can we use @Transactional on private methods? ✔ What is the default scope of Spring beans? 💬 If you're preparing for product-based companies like TCS, EPAM, Accenture, or startups — these annotations are MUST-KNOW. Follow for more 🚀 #Java #SpringBoot #BackendDeveloper #Microservices #InterviewPrep #SoftwareEngineer
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! 💡 Component Annotations Used to define Spring-managed beans in your application. @Component- General-purpose stereotype annotation. Spring detects it during component scanning and manages its lifecycle as a bean. @Service- Specialization of @Component, intended for service-layer classes containing business logic. @Repository- Indicates a data access object (DAO). Also enables exception translation, converting DB-specific exceptions into Spring's DataAccessException. @Controller- Marks a class as a web controller in Spring MVC. It handles HTTP requests and returns views. @RestController- Combines @Controller and @ResponseBody, meaning every method returns data (like JSON/XML) instead of a view. *Configuration Annotations Define beans, control scanning, and manage environment setup.. @Configuration- Marks a class that contains @Bean definitions. Spring uses it to generate bean definitions and service requests. @Bean - Declares a bean to be managed by Spring. Used in methods inside a @Configuration class. @ComponentScan Tells Spring where to scan for components (classes annotated with @Component, Service, etc.). @PropertySource- Loads properties from a properties file into Spring's Environment. @Value- Injects values from property files or expressions into fields or methods. @Import- Allows importing additional configuration classes. @Profile- Conditionally registers a bean based on the active Spring profile (dev, test, prod, etc.). @Conditional- Register a bean only if a specific condition is met (e.g., presence of a class or property). @Lazy - Defers bean initialization until it's actually needed. Great for performance optimization. @Dependson- Specifies bean initialization order by declaring dependencies. #Java #SpringBoot #Microservices #BackendDeveloper #InterviewPreparation #JavaDeveloper #Coding #TechCareers
To view or add a comment, sign in
-
🚀 Top 5 Tough Java Questions Asked in GCC Interviews (2026) — With Answers Cracking GCC companies today is not about syntax… it’s about how you think, design, and scale systems. Here are 5 real tough Java questions trending in interviews 👇 --- 1️⃣ Explain Java Memory Model (JMM) & Happens-Before Relationship 💡 Why they ask: Tests deep concurrency understanding ✅ Answer: - JMM defines how threads interact through memory (heap, stack) - Happens-before ensures visibility + ordering guarantees - Example: - Write to variable → happens-before → another thread reads it - Without it → race conditions / stale data 👉 Key point: "volatile", "synchronized", locks enforce happens-before --- 2️⃣ How would you design a thread-safe Singleton in Java? 💡 Why they ask: Tests design + concurrency ✅ Answer (Best approach): public class Singleton { private Singleton() {} private static class Holder { private static final Singleton INSTANCE = new Singleton(); } public static Singleton getInstance() { return Holder.INSTANCE; } } ✔ Lazy loaded ✔ Thread-safe ✔ No synchronization overhead --- 3️⃣ HashMap Internals – What happens during collision? 💡 Why they ask: Tests core + performance thinking ✅ Answer: - Uses array + linked list / tree (Java 8+) - Collision → same bucket index - Java 8: - LinkedList → converts to Red-Black Tree after threshold - Improves from O(n) → O(log n) 👉 Key: Good "hashCode()" + "equals()" matters --- 4️⃣ Difference between "synchronized", "ReentrantLock", and "volatile" 💡 Why they ask: Real-world concurrency decisions ✅ Answer: Feature| synchronized| ReentrantLock| volatile Locking| Yes| Yes (flexible)| No Fairness| No| Yes (optional)| No Interruptible| No| Yes| No Visibility| Yes| Yes| Yes 👉 Use: - "volatile" → visibility only - "synchronized" → simple locking - "ReentrantLock" → advanced control --- 5️⃣ How would you design a scalable REST API using Spring Boot? 💡 Why they ask: System design + real work ✅ Answer: - Use layered architecture (Controller → Service → Repository) - Apply: - Caching (Redis) - Async processing ("CompletableFuture") - Circuit breaker (Resilience4j) - Ensure: - Idempotency - Rate limiting - Proper exception handling 👉 Bonus: Use microservices + event-driven design --- 🔥 Pro Tip: In 2026, interviews focus on: - JVM internals - Concurrency - System design - Real production scenarios --- 💬 Which question surprised you the most? ♻️ Save this for your next interview prep! Do comment and like for more reach!!! #Java #GCC #InterviewPrep #Backend #SpringBoot #SoftwareEngineering
To view or add a comment, sign in
-
𝟒𝟎 𝐄𝐬𝐬𝐞𝐧𝐭𝐢𝐚𝐥 𝐒𝐩𝐫𝐢𝐧𝐠 𝐁𝐨𝐨𝐭 𝐀𝐧𝐧𝐨𝐭𝐚𝐭𝐢𝐨𝐧𝐬 𝐟𝐨𝐫 𝐃𝐞𝐯𝐞𝐥𝐨𝐩𝐞𝐫s Spring Boot annotations simplify Java application development, crucial for interview preparation. Here’s a curated list: 1. @Required: Ensures a bean property must be set. 2. @Autowired: Automatically injects dependencies. 3. @Configuration: Declares @Bean methods in a class. 4. @ComponentScan: Configures component scanning. 5. @Bean: Produces a managed Spring bean. 6. @Qualifier: Specifies bean injection options. 7. @Lazy: Delays bean initialization. 8. @Value: Injects a property value. 9. @Component: Marks a Spring component. 10. @Controller: Handles MVC views. 11. @Service: Marks service layer components. 12. @Repository: Marks DAOs with exception translation. 13. @EnableAutoConfiguration: Enables auto-configuration. 14. @SpringBootApplication: Configures Spring Boot app. 15. @RequestMapping: Maps HTTP methods. 16. @GetMapping: Handles HTTP GET requests. 17. @PostMapping: Maps HTTP POST requests. 18. @PutMapping: Maps HTTP PUT requests. 19. @DeleteMapping: Maps HTTP DELETE requests. 20. @PatchMapping: Maps HTTP PATCH requests. 21. @RequestBody: Binds HTTP request body. 22. @ResponseBody: Binds HTTP response body. 23. @PathVariable: Extracts URI values. 24. @RequestParam: Extracts query parameters. 25. @RequestHeader: Extracts header values. 26. @RestController: Combines @Controller and @ResponseBody. 27. @RequestAttribute: Binds request attributes. 28. @CookieValue: Binds HTTP cookie values. 29. @CrossOrigin: Enables CORS. 30. @Profile: Specifies bean profiles. 31. @Scope: Defines bean scopes. 32. @Conditional: Registers beans conditionally. 33. @Primary: Sets primary autowired beans. 34. @PropertySource: Adds PropertySource to Environment. 35. @EnableAsync: Enables asynchronous methods. 36. @EnableScheduling: Enables scheduled tasks. 37. @EnableCaching: Enables caching. 38. @RestControllerAdvice: Specializes @ControllerAdvice for REST. 39. @JsonIgnoreProperties: Ignores JSON properties. 40. @JsonProperty: Maps JSON properties to Java fields. Preparing for interviews? Start revising these today 𝗜’𝘃𝗲 𝗽𝗿𝗲𝗽𝗮𝗿𝗲𝗱 𝗶𝗻 𝗗𝗲𝗽𝘁𝗵 𝗝𝗮𝘃𝗮 𝗦𝗽𝗿𝗶𝗻𝗴𝗯𝗼𝗼𝘁 𝗯𝗮𝗰𝗸𝗲𝗻𝗱 𝗚𝘂𝗶𝗱𝗲, 𝟏𝟬𝟬𝟬+ 𝗽𝗲𝗼𝗽𝗹𝗲 𝗮𝗿𝗲 𝗮𝗹𝗿𝗲𝗮𝗱𝘆 𝘂𝘀𝗶𝗻𝗴 𝗶𝘁. 𝗚𝗲𝘁 𝘁𝗵𝗲 𝗴𝘂𝗶𝗱𝗲 𝗵𝗲𝗿𝗲: https://lnkd.in/dfhsJKMj keep learning, keep sharing ! #backend #java #springboot
To view or add a comment, sign in
-
🚀 Java Backend Interview Series – Question #77 Q77. How does Dependency Injection (DI) work internally in Spring Boot? We use Dependency Injection (DI) every day in Spring Boot: 👉 @Autowired 👉 Constructor Injection 👉 @Component, @Service, @Repository But in interviews, a deeper question is asked: 👉 “What happens internally when Spring injects dependencies?” Let’s break it down step by step 👇 🔹 1️⃣ What is Dependency Injection? Dependency Injection means: 👉 Spring provides required objects (dependencies) instead of creating them manually Example: @Service class OrderService { private final PaymentService paymentService; public OrderService(PaymentService paymentService) { this.paymentService = paymentService; } } 📌 Here, Spring injects PaymentService automatically. 🔹 2️⃣ Role of Spring IoC Container At the core of DI is: 👉 IoC (Inversion of Control) Container Spring uses: ✔ ApplicationContext ✔ BeanFactory These containers are responsible for: Creating beans Managing lifecycle Injecting dependencies 🔹 3️⃣ Step-by-Step Internal Flow Here’s what happens internally: 🔸 Step 1: Component Scanning Spring scans classes annotated with: @Component @Service @Repository @Controller 👉 Registers them as beans 🔸 Step 2: Bean Definition Creation Spring creates metadata called: 👉 BeanDefinition It contains: ✔ Class type ✔ Scope ✔ Dependencies 🔸 Step 3: Bean Instantiation Spring creates objects using: ✔ Constructor ✔ Factory methods 🔸 Step 4: Dependency Injection Spring resolves dependencies: ✔ Constructor Injection (preferred) ✔ Field Injection ✔ Setter Injection It finds required beans from the container and injects them automatically. 🔸 Step 5: Bean Initialization Spring performs: ✔ @PostConstruct methods ✔ Custom initialization logic 🔸 Step 6: Bean Ready to Use The fully initialized bean is now: 👉 Managed and available for use across the application 🔹 4️⃣ How Spring Resolves Dependencies Spring uses: ✔ Type-based resolution ✔ @Qualifier (if multiple beans exist) ✔ @Primary (default bean selection) 🔹 5️⃣ Real-World Backend Insight DI helps in: ✔ Loose coupling ✔ Better testability (mocking) ✔ Cleaner architecture 👉 This is why Spring apps are modular and scalable 🎯 Interview Tip A tricky question: 👉 “What happens if multiple beans of the same type exist?” Answer: ❌ Ambiguity error ✔ Solve using: @Qualifier @Primary 💬 Follow-up Interview Question What is the difference between Constructor Injection and Field Injection, and which one is better? #Java #SpringBoot #DependencyInjection #IoC #JavaDeveloper #BackendDevelopment #CodingInterview #TechInterview #SoftwareEngineering #Microservices #Programming #CleanCode #SystemDesign #SpringFramework
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 Backend Interview Series – Question #94 Q94. What is Maven Dependency Management and why is it important? In any Java backend project, managing external libraries is crucial. That’s where Maven Dependency Management comes into play 🔥 Let’s break it down 👇 🔹 1️⃣ What is Maven Dependency Management? 👉 It is the process of: ✔ Managing project dependencies (libraries) ✔ Controlling their versions ✔ Handling transitive dependencies automatically All this is defined in: 👉 pom.xml 🔹 2️⃣ Example <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>3.0.0</version> </dependency> </dependencies> 📌 Maven will: ✔ Download the dependency ✔ Download its transitive dependencies ✔ Add them to your project 🔹 3️⃣ What is Dependency Management Section? <dependencyManagement> <dependencies> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.30</version> </dependency> </dependencies> </dependencyManagement> 📌 Purpose: ✔ Centralized version control ✔ Avoid version conflicts 🔹 4️⃣ Why is it Important? ✔ Prevents dependency conflicts ✔ Ensures consistent versions across modules ✔ Simplifies large project management ✔ Improves build stability 🔹 5️⃣ Key Concepts 🔸 Transitive Dependencies 👉 Dependencies of dependencies 🔸 Dependency Conflict 👉 Multiple versions of same library ✔ Maven resolves using: 👉 Nearest definition wins 🔹 6️⃣ Real-World Backend Insight In large applications: ✔ Hundreds of dependencies exist ✔ Without management → chaos ❌ 👉 Maven ensures: ✔ Clean and maintainable builds 🔹 7️⃣ Best Practices ✔ Use dependencyManagement for version control ✔ Avoid duplicate dependencies ✔ Use Spring Boot parent POM for default versions 🎯 Interview Tip A tricky question: 👉 “What happens if two dependencies have different versions of the same library?” Answer: ✔ Maven uses nearest dependency in the tree 💬 Follow-up Interview Question What is the difference between dependencies and dependencyManagement in Maven? #Java #Maven #DependencyManagement #BuildTools #BackendDevelopment #JavaDeveloper #CodingInterview #TechInterview #SoftwareEngineering #SpringBoot #Microservices #Programming #DeveloperCommunity #SystemDesign #CleanCode
To view or add a comment, sign in
-
-
🚀 30 Days of Java Interview Questions – Day 14 💡 Question: What is the Java Collections Framework? 🔹 What is Java Collections Framework? Java Collections Framework (JCF) is a set of classes and interfaces used to store and manipulate groups of data efficiently. 🔹 Main Interfaces List • Allows duplicates • Maintains insertion order • Examples: ArrayList, LinkedList Set • No duplicates allowed • Unordered (HashSet) / Ordered (TreeSet) Queue • Follows FIFO (First In First Out) • Used in scheduling and buffering Map • Stores key-value pairs • Keys are unique • Examples: HashMap, TreeMap 🔹 Example ```java id="f8k2la" import java.util.*; public class Test { public static void main(String[] args) { List<String> list = new ArrayList<>(); list.add("Apple"); list.add("Banana"); System.out.println(list); } } ``` Output: [Apple, Banana] ⚡ Quick Summary • List → ordered, allows duplicates • Set → no duplicates • Queue → FIFO structure • Map → key-value storage 📌 Interview Tip Always choose the right collection based on: • Performance • Ordering requirement • Duplicate handling Follow this series for 30 Days of Java Interview Questions. Tomorrow: Day 15 #java #javadeveloper #codinginterview #backenddeveloper #softwareengineer #programming #developers #tech
To view or add a comment, sign in
-
-
Top 100 Java Spring Boot interview questions 1-40 1. Core Spring Boot basics 1. What is Spring Boot? How is it different from Spring Framework? 2. What are the main advantages of using Spring Boot? 3. Explain the role of Spring Boot Starters? 4. What is `spring-boot-starter-parent` and why is it used? 5. How does Spring Boot simplify dependency management? 6. What is the default embedded server in Spring Boot? 7. How do you change the embedded server in a Spring Boot application? 8. What is the purpose of `@SpringBootApplication`? 9. What does `@EnableAutoConfiguration` do? 10. How does Spring Boot auto‑configuration work under the hood? *** ### 2. Configuration and properties 11. How do you externalize configuration in Spring Boot? 12. What is the difference between `application.properties` and `application.yml`? 13. How do you define multiple profiles in Spring Boot? 14. How do you activate a specific profile at runtime? 15. How do you inject configuration values into a bean using `@Value`? 16. What is `@ConfigurationProperties` and when would you use it? 17. How do you validate configuration properties in Spring Boot? 18. How can you reload configuration without restarting the application? 19. What is the `@PropertySource` annotation and where is it typically used? 20. How does Spring Boot handle hierarchical property sources (e.g., profile vs default)? *** ### 3. Bean lifecycle, DI, and IoC 21. How does Spring Boot use dependency injection and IoC? 22. What is the difference between `@Component`, `@Service`, `@Repository`, and `@Controller`? 23. What is the default scope of a Spring bean? 24. How do you define a prototype‑scoped bean? 25. How do you define a custom bean using `@Bean` inside a `@Configuration` class? 26. What is the bean lifecycle in Spring Boot? 27. How do `@PostConstruct` and `@PreDestroy` work? 28. How do you resolve dependency‑injection conflicts when multiple beans implement the same interface? 29. What is `@Qualifier` and how is it used? 30. How can you use constructor‑based DI instead of field injection? *** ### 4. Spring Boot annotations 31. What is the difference between `@RestController` and `@Controller`? 32. What is the purpose of `@RequestMapping`, `@GetMapping`, `@PostMapping`, etc.? 33. What is `@PathVariable` and how is it used? 34. What is `@RequestParam` and when would you use it? 35. What is `@RequestBody` and `@ResponseBody`? 36. What is `@Autowired` and in which cases can it fail? 37. What is `@ConditionalOn…` family of annotations used for? 38. What is `@Profile` and how does it interact with `@Conditional`? 39. What is `@Primary` and when would you use it? 40. What is the role of `@Lazy` in Spring Boot? *** #java #interviewexperience #hiring #interviewpreparation
To view or add a comment, sign in
-
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