https://github.com/bikkimahato/spring-interview-questions
Welcome to the Spring Interview Questions repository! This repository is your go-to resource for preparing for Spring Framework interviews. It includes a comprehensive collection of questions and answers covering a wide range of topics and difficulty levels.
https://github.com/bikkimahato/spring-interview-questions
spring spring-core
Last synced: 11 months ago
JSON representation
Welcome to the Spring Interview Questions repository! This repository is your go-to resource for preparing for Spring Framework interviews. It includes a comprehensive collection of questions and answers covering a wide range of topics and difficulty levels.
- Host: GitHub
- URL: https://github.com/bikkimahato/spring-interview-questions
- Owner: bikkimahato
- Created: 2024-11-25T18:16:08.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-25T18:23:35.000Z (over 1 year ago)
- Last Synced: 2025-04-15T01:52:04.100Z (about 1 year ago)
- Topics: spring, spring-core
- Homepage:
- Size: 184 KB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Interview Questions

Welcome to the Spring Interview Questions repository! This repository is your go-to resource for preparing for Spring Framework interviews. It includes a comprehensive collection of questions and answers covering a wide range of topics and difficulty levels.
## Introduction
This repository aims to help you prepare for Spring Framework interviews by providing a curated list of commonly asked questions along with detailed answers. Whether you're a beginner or an experienced developer, this resource will help you enhance your Spring knowledge and be well-prepared for your next interview.
## Topics Covered
- [Spring Core](#spring-core)
- [Spring MVC](#spring-mvc)
- [Spring Data JPA](#spring-data-jpa)
- [Spring Security](#spring-security)
- [Spring AOP](#spring-aop)
- [Spring Cloud](#spring-cloud)
- [Spring Batch](#spring-batch)
- [Spring Integration](#spring-integration)
## How to Use
To use this repository, browse through the topics and questions. You can also clone the repository to your local machine for offline access.
```sh
git clone https://github.com/bikkimahato/spring-interview-questions.git
```
## Contributing
Contributions are welcome! If you have additional questions, answers, or improvements, please fork the repository and create a pull request. For major changes, please open an issue first to discuss what you would like to change.
---
Happy Interview Preparation!
Happy coding! If you find this repository helpful, please give it a star ⭐ and share it with others.
---
## Spring Core
### Table of Contents
### Level : Spring Core Easy
| No. | Questions |
| --- | --------- |
| 1 | [What is the Spring Framework?](#1-what-is-the-spring-framework) |
| 2 | [What are the advantages of using Spring Framework?](#2-what-are-the-advantages-of-using-spring-framework) |
| 3 | [Explain Dependency Injection.](#3-explain-dependency-injection) |
| 4 | [What are the different types of Dependency Injection?](#4-what-are-the-different-types-of-dependency-injection) |
| 5 | [What is the BeanFactory in Spring?](#5-what-is-the-beanfactory-in-spring) |
| 6 | [What is the ApplicationContext in Spring?](#6-what-is-the-applicationcontext-in-spring) |
| 7 | [What is the difference between BeanFactory and ApplicationContext?](#7-what-is-the-difference-between-beanfactory-and-applicationcontext) |
| 8 | [How do you configure a Spring application using XML?](#8-how-do-you-configure-a-spring-application-using-xml) |
| 9 | [What is a Spring Bean?](#9-what-is-a-spring-bean) |
| 10 | [What are the different scopes of Spring Beans?](#10-what-are-the-different-scopes-of-spring-beans) |
| 11 | [How do you define a Spring Bean in XML configuration?](#11-how-do-you-define-a-spring-bean-in-xml-configuration) |
| 12 | [What is the default scope of a Spring Bean?](#12-what-is-the-default-scope-of-a-spring-bean) |
| 13 | [How do you inject a bean using constructor injection?](#13-how-do-you-inject-a-bean-using-constructor-injection) |
| 14 | [How do you inject a bean using setter injection?](#14-how-do-you-inject-a-bean-using-setter-injection) |
| 15 | [What is the role of the @Autowired annotation?](#15-what-is-the-role-of-the-autowired-annotation) |
| 16 | [What is the purpose of the @Component annotation?](#16-what-is-the-purpose-of-the-component-annotation) |
| 17 | [What are Spring stereotypes?](#17-what-are-spring-stereotypes) |
| 18 | [How do you enable component scanning in Spring?](#18-how-do-you-enable-component-scanning-in-spring) |
| 19 | [What is the difference between @Component, @Service, @Repository, and @Controller?](#19-what-is-the-difference-between-component-service-repository-and-controller) |
| 20 | [How do you handle bean autowiring in Spring?](#20-how-do-you-handle-bean-autowiring-in-spring) |
| 21 | [What is the use of the @Qualifier annotation?](#21-what-is-the-use-of-the-qualifier-annotation) |
| 22 | [What is the Spring IoC container?](#22-what-is-the-spring-ioc-container) |
| 23 | [Explain the lifecycle of a Spring Bean.](#23-explain-the-lifecycle-of-a-spring-bean) |
| 24 | [What is Spring AOP framework?](#24-what-is-spring-aop-framework) |
| 25 | [What is a pointcut in Spring AOP?](#25-what-is-a-pointcut-in-spring-aop) |
| 26 | [What is an advice in Spring AOP?](#26-what-is-an-advice-in-spring-aop) |
| 27 | [What are the different types of advice in Spring AOP?](#27-what-are-the-different-types-of-advice-in-spring-aop) |
| 28 | [What is a join point in Spring AOP?](#28-what-is-a-join-point-in-spring-aop) |
| 29 | [What is a proxy in Spring AOP?](#29-what-is-a-proxy-in-spring-aop) |
| 30 | [How do you configure AOP in Spring using XML?](#30-how-do-you-configure-aop-in-spring-using-xml) |
| 31 | [Explain the concept of Aspect in Spring AOP.](#31-explain-the-concept-of-aspect-in-spring-aop) |
| 32 | [What is the @Aspect annotation used for?](#32-what-is-the-aspect-annotation-used-for) |
| 33 | [How do you configure transactions in Spring?](#33-how-do-you-configure-transactions-in-spring) |
| 34 | [What is the @Transactional annotation?](#34-what-is-the-transactional-annotation) |
| 35 | [What is the difference between programmatic and declarative transaction management?](#35-what-is-the-difference-between-programmatic-and-declarative-transaction-management) |
| 36 | [How do you manage properties in Spring?](#36-how-do-you-manage-properties-in-spring) |
| 37 | [What is the Environment abstraction in Spring?](#37-what-is-the-environment-abstraction-in-spring) |
| 38 | [How do you use @PropertySource to load properties in Spring?](#38-how-do-you-use-propertysource-to-load-properties-in-spring) |
| 39 | [What is Spring Expression Language (SpEL)?](#39-what-is-spring-expression-language-spel) |
| 40 | [How do you use SpEL in Spring applications?](#40-how-do-you-use-spel-in-spring-applications) |
| 41 | [What is the purpose of the @Value annotation?](#41-what-is-the-purpose-of-the-value-annotation) |
| 42 | [What is the Spring JDBC template?](#42-what-is-the-spring-jdbc-template) |
| 43 | [How do you configure a DataSource in Spring?](#43-how-do-you-configure-a-datasource-in-spring) |
| 44 | [How do you use the JdbcTemplate in Spring?](#44-how-do-you-use-the-jdbctemplate-in-spring) |
| 45 | [What is the purpose of the @Repository annotation?](#45-what-is-the-purpose-of-the-repository-annotation) |
| 46 | [What is the Spring Data JPA?](#46-what-is-the-spring-data-jpa) |
| 47 | [How do you define a repository in Spring Data JPA?](#47-how-do-you-define-a-repository-in-spring-data-jpa) |
| 48 | [What is the purpose of the @Entity annotation?](#48-what-is-the-purpose-of-the-entity-annotation) |
| 49 | [What is the use of the @Id annotation in Spring Data JPA?](#49-what-is-the-use-of-the-id-annotation-in-spring-data-jpa) |
| 50 | [How do you define a primary key generation strategy in Spring Data JPA?](#50-how-do-you-define-a-primary-key-generation-strategy-in-spring-data-jpa) |
### Level : Spring Core Medium
| No. | Questions |
| --- | --------- |
| 51 | [How does Spring manage transactions?](#51-how-does-spring-manage-transactions) |
| 52 | [Explain the concept of Bean Post Processors.](#52-explain-the-concept-of-bean-post-processors) |
| 53 | [How do you create a custom Bean Post Processor?](#53-how-do-you-create-a-custom-bean-post-processor) |
| 54 | [What is the BeanFactoryPostProcessor and how is it different from BeanPostProcessor?](#54-what-is-the-beanfactorypostprocessor-and-how-is-it-different-from-beanpostprocessor) |
| 55 | [How does Spring handle circular dependencies?](#55-how-does-spring-handle-circular-dependencies) |
| 56 | [What is the use of the @Scope annotation?](#56-what-is-the-use-of-the-scope-annotation) |
| 57 | [Explain the concept of Spring Profiles.](#57-explain-the-concept-of-spring-profiles) |
| 58 | [How do you manage environment-specific properties in Spring?](#58-how-do-you-manage-environment-specific-properties-in-spring) |
| 59 | [What is the role of the @Profile annotation?](#59-what-is-the-role-of-the-profile-annotation) |
| 60 | [How do you enable asynchronous method execution in Spring?](#60-how-do-you-enable-asynchronous-method-execution-in-spring) |
| 61 | [What is the use of the @Async annotation?](#61-what-is-the-use-of-the-async-annotation) |
| 62 | [How do you implement caching in Spring?](#62-how-do-you-implement-caching-in-spring) |
| 63 | [What is the use of the @Cacheable annotation?](#63-what-is-the-use-of-the-cacheable-annotation) |
| 64 | [How do you configure a cache manager in Spring?](#64-how-do-you-configure-a-cache-manager-in-spring) |
| 65 | [What is the Spring Event model?](#65-what-is-the-spring-event-model) |
| 66 | [How do you publish and listen to events in Spring?](#66-how-do-you-publish-and-listen-to-events-in-spring) |
| 67 | [What is the use of the @EventListener annotation?](#67-what-is-the-use-of-the-eventlistener-annotation) |
| 68 | [What is Spring's Task Scheduler?](#68-what-is-springs-task-scheduler) |
| 69 | [How do you schedule tasks in Spring?](#69-how-do-you-schedule-tasks-in-spring) |
| 70 | [What is the use of the @Scheduled annotation?](#70-what-is-the-use-of-the-scheduled-annotation) |
| 71 | [What is the Spring Web MVC framework?](#71-what-is-the-spring-web-mvc-framework) |
| 72 | [How do you configure a DispatcherServlet in Spring?](#72-how-do-you-configure-a-dispatcherservlet-in-spring) |
| 73 | [What is the role of the @Controller annotation?](#73-what-is-the-role-of-the-controller-annotation) |
| 74 | [How do you handle form submissions in Spring MVC?](#74-how-do-you-handle-form-submissions-in-spring-mvc) |
| 75 | [What is the use of the @RequestMapping annotation?](#75-what-is-the-use-of-the-requestmapping-annotation) |
| 76 | [How do you handle exceptions in Spring MVC?](#76-how-do-you-handle-exceptions-in-spring-mvc) |
| 77 | [What is the use of the @ExceptionHandler annotation?](#77-what-is-the-use-of-the-exceptionhandler-annotation) |
| 78 | [How do you configure view resolvers in Spring MVC?](#78-how-do-you-configure-view-resolvers-in-spring-mvc) |
| 79 | [What is the use of the @ModelAttribute annotation?](#79-what-is-the-use-of-the-modelattribute-annotation) |
| 80 | [How do you perform validation in Spring MVC?](#80-how-do-you-perform-validation-in-spring-mvc) |
| 81 | [What is the use of the @Valid annotation?](#81-what-is-the-use-of-the-valid-annotation) |
| 82 | [How do you handle file uploads in Spring MVC?](#82-how-do-you-handle-file-uploads-in-spring-mvc) |
| 83 | [What is the use of the MultipartResolver in Spring MVC?](#83-what-is-the-use-of-the-multipartresolver-in-spring-mvc) |
| 84 | [Explain the concept of RestTemplate in Spring.](#84-explain-the-concept-of-resttemplate-in-spring) |
| 85 | [How do you configure RestTemplate in Spring?](#85-how-do-you-configure-resttemplate-in-spring) |
| 86 | [How do you make HTTP requests using RestTemplate?](#86-how-do-you-make-http-requests-using-resttemplate) |
| 87 | [What is the Spring WebFlux framework?](#87-what-is-the-spring-webflux-framework) |
| 88 | [How do you configure a WebFlux application in Spring?](#88-how-do-you-configure-a-webflux-application-in-spring) |
| 89 | [What is the role of the @RestController annotation?](#89-what-is-the-role-of-the-restcontroller-annotation) |
| 90 | [How do you handle reactive streams in Spring WebFlux?](#90-how-do-you-handle-reactive-streams-in-spring-webflux) |
| 91 | [What is the Spring Boot framework?](#91-what-is-the-spring-boot-framework) |
| 92 | [How do you configure a Spring Boot application?](#92-how-do-you-configure-a-spring-boot-application) |
| 93 | [What are the benefits of using Spring Boot?](#93-what-are-the-benefits-of-using-spring-boot) |
| 94 | [How do you create a RESTful web service using Spring Boot?](#94-how-do-you-create-a-restful-web-service-using-spring-boot) |
| 95 | [What is the role of the application.properties file in Spring Boot?](#95-what-is-the-role-of-the-application-properties-file-in-spring-boot) |
| 96 | [How do you configure logging in Spring Boot?](#96-how-do-you-configure-logging-in-spring-boot) |
| 97 | [How do you handle exceptions in a Spring Boot application?](#97-how-do-you-handle-exceptions-in-a-spring-boot-application) |
| 98 | [What is the use of the @SpringBootApplication annotation?](#98-what-is-the-use-of-the-springbootapplication-annotation) |
| 99 | [How do you run a Spring Boot application?](#99-how-do-you-run-a-spring-boot-application) |
| 100 | [How do you test a Spring Boot application?](#100-how-do-you-test-a-spring-boot-application) |
### Level : Spring Core Hard
| No. | Questions |
| --- | --------- |
| 101 | [Explain the concept of Reactive Programming in Spring.](#101-explain-the-concept-of-reactive-programming-in-spring) |
| 102 | [How does Spring WebFlux handle backpressure?](#102-how-does-spring-webflux-handle-backpressure) |
| 103 | [What is the difference between Spring MVC and Spring WebFlux?](#103-what-is-the-difference-between-spring-mvc-and-spring-webflux) |
| 104 | [How do you configure security in a Spring application?](#104-how-do-you-configure-security-in-a-spring-application) |
| 105 | [What is the role of the @EnableWebSecurity annotation?](#105-what-is-the-role-of-the-enablewebsecurity-annotation) |
| 106 | [How do you implement OAuth2 authentication in Spring Security?](#106-how-do-you-implement-oauth2-authentication-in-spring-security) |
| 107 | [What is the use of the @PreAuthorize annotation?](#107-what-is-the-use-of-the-preauthorize-annotation) |
| 108 | [How do you implement method-level security in Spring?](#108-how-do-you-implement-method-level-security-in-spring) |
| 109 | [How do you configure a custom authentication provider in Spring Security?](#109-how-do-you-configure-a-custom-authentication-provider-in-spring-security) |
| 110 | [What is the purpose of the SecurityContextHolder in Spring Security?](#110-what-is-the-purpose-of-the-securitycontextholder-in-spring-security) |
| 111 | [Explain the concept of CSRF protection in Spring Security.](#111-explain-the-concept-of-csrf-protection-in-spring-security) |
| 112 | [How do you configure session management in Spring Security?](#112-how-do-you-configure-session-management-in-spring-security) |
| 113 | [What is the use of the @EnableAspectJAutoProxy annotation?](#113-what-is-the-use-of-the-enableaspectjautoproxy-annotation) |
| 114 | [How do you implement global exception handling in Spring?](#114-how-do-you-implement-global-exception-handling-in-spring) |
| 115 | [What is the use of the @ControllerAdvice annotation?](#115-what-is-the-use-of-the-controlleradvice-annotation) |
| 116 | [How do you configure internationalization in a Spring application?](#116-how-do-you-configure-internationalization-in-a-spring-application) |
| 117 | [What is the use of the MessageSource interface in Spring?](#117-what-is-the-use-of-the-messagesource-interface-in-spring) |
| 118 | [How do you create a custom validator in Spring?](#118-how-do-you-create-a-custom-validator-in-spring) |
| 119 | [What is the use of the @InitBinder annotation?](#119-what-is-the-use-of-the-initbinder-annotation) |
| 120 | [How do you configure a custom property editor in Spring?](#120-how-do-you-configure-a-custom-property-editor-in-spring) |
| 121 | [Explain the concept of Spring Cloud.](#121-explain-the-concept-of-spring-cloud) |
| 122 | [How do you configure a microservice using Spring Cloud?](#122-how-do-you-configure-a-microservice-using-spring-cloud) |
| 123 | [What is the use of the @EnableEurekaClient annotation?](#123-what-is-the-use-of-the-enableeurekaclient-annotation) |
| 124 | [How do you configure load balancing in Spring Cloud?](#124-how-do-you-configure-load-balancing-in-spring-cloud) |
| 125 | [What is the use of the @EnableFeignClients annotation?](#125-what-is-the-use-of-the-enablefeignclients-annotation) |
| 126 | [How do you implement circuit breaker pattern in Spring Cloud?](#126-how-do-you-implement-circuit-breaker-pattern-in-spring-cloud) |
| 127 | [What is the use of the @EnableCircuitBreaker annotation?](#127-what-is-the-use-of-the-enablecircuitbreaker-annotation) |
| 128 | [How do you configure a distributed tracing system in Spring Cloud?](#128-how-do-you-configure-a-distributed-tracing-system-in-spring-cloud) |
| 129 | [What is the use of the @EnableHystrixDashboard annotation?](#129-what-is-the-use-of-the-enablehystrixdashboard-annotation) |
| 130 | [How do you configure a service gateway in Spring Cloud?](#130-how-do-you-configure-a-service-gateway-in-spring-cloud) |
| 131 | [What is the use of the @EnableZuulProxy annotation?](#131-what-is-the-use-of-the-enablezuulproxy-annotation) |
| 132 | [How do you implement API versioning in a Spring application?](#132-how-do-you-implement-api-versioning-in-a-spring-application) |
| 133 | [What is the use of the @JsonView annotation in Spring?](#133-what-is-the-use-of-the-jsonview-annotation-in-spring) |
| 134 | [How do you configure a custom JSON serializer in Spring?](#134-how-do-you-configure-a-custom-json-serializer-in-spring) |
| 135 | [What is the use of the @JsonIgnore annotation?](#135-what-is-the-use-of-the-jsonignore-annotation) |
| 136 | [How do you configure a custom exception handler in Spring?](#136-how-do-you-configure-a-custom-exception-handler-in-spring) |
| 137 | [What is the use of the @RestControllerAdvice annotation?](#137-what-is-the-use-of-the-restcontrolleradvice-annotation) |
| 138 | [How do you configure CORS in a Spring application?](#138-how-do-you-configure-cors-in-a-spring-application) |
| 139 | [What is the use of the @CrossOrigin annotation?](#139-what-is-the-use-of-the-crossorigin-annotation) |
| 140 | [How do you configure a custom HTTP message converter in Spring?](#140-how-do-you-configure-a-custom-http-message-converter-in-spring) |
| 141 | [What is the use of the HttpMessageConverter interface in Spring?](#141-what-is-the-use-of-the-httpmessageconverter-interface-in-spring) |
| 142 | [How do you configure a custom view resolver in Spring?](#142-how-do-you-configure-a-custom-view-resolver-in-spring) |
| 143 | [What is the use of the ViewResolver interface in Spring?](#143-what-is-the-use-of-the-viewresolver-interface-in-spring) |
| 144 | [How do you configure a custom locale resolver in Spring?](#144-how-do-you-configure-a-custom-locale-resolver-in-spring) |
| 145 | [What is the use of the LocaleResolver interface in Spring?](#145-what-is-the-use-of-the-localeresolver-interface-in-spring) |
| 146 | [How do you configure a custom theme resolver in Spring?](#146-how-do-you-configure-a-custom-theme-resolver-in-spring) |
| 147 | [What is the use of the ThemeResolver interface in Spring?](#147-what-is-the-use-of-the-themeresolver-interface-in-spring) |
| 148 | [How do you configure a custom session attribute in Spring?](#148-how-do-you-configure-a-custom-session-attribute-in-spring) |
| 149 | [What is the use of the SessionAttributeStore interface in Spring?](#149-what-is-the-use-of-the-sessionattributestore-interface-in-spring) |
| 150 | [How do you configure a custom handler interceptor in Spring?](#150-how-do-you-configure-a-custom-handler-interceptor-in-spring) |
## Spring MVC
### Table of Contents
### Level : Spring MVC Easy
| No. | Questions |
| --- | --------- |
| 1 | [What is Spring MVC?](#1-what-is-spring-mvc) |
| 2 | [Explain the architecture of Spring MVC.](#2-explain-the-architecture-of-spring-mvc) |
| 3 | [What are the main components of Spring MVC?](#3-what-are-the-main-components-of-spring-mvc) |
| 4 | [How do you configure Spring MVC in a web application?](#4-how-do-you-configure-spring-mvc-in-a-web-application) |
| 5 | [What is the role of DispatcherServlet in Spring MVC?](#5-what-is-the-role-of-dispatcherservlet-in-spring-mvc) |
| 6 | [How do you define a controller in Spring MVC?](#6-how-do-you-define-a-controller-in-spring-mvc) |
| 7 | [What is the use of @RequestMapping annotation?](#7-what-is-the-use-of-requestmapping-annotation) |
| 8 | [How do you handle form submission in Spring MVC?](#8-how-do-you-handle-form-submission-in-spring-mvc) |
| 9 | [What is ModelAndView in Spring MVC?](#9-what-is-modelandview-in-spring-mvc) |
| 10 | [How do you return JSON data from a Spring MVC controller?](#10-how-do-you-return-json-data-from-a-spring-mvc-controller) |
| 11 | [Explain the difference between @Controller and @RestController.](#11-explain-the-difference-between-controller-and-restcontroller) |
| 12 | [What is the use of @PathVariable annotation?](#12-what-is-the-use-of-pathvariable-annotation) |
| 13 | [How do you inject a service into a Spring MVC controller?](#13-how-do-you-inject-a-service-into-a-spring-mvc-controller) |
| 14 | [What is the role of ViewResolver in Spring MVC?](#14-what-is-the-role-of-viewresolver-in-spring-mvc) |
| 15 | [How do you handle exceptions in Spring MVC?](#15-how-do-you-handle-exceptions-in-spring-mvc) |
| 16 | [What is the difference between @RequestParam and @PathVariable?](#16-what-is-the-difference-between-requestparam-and-pathvariable) |
| 17 | [How do you perform validation in Spring MVC?](#17-how-do-you-perform-validation-in-spring-mvc) |
| 18 | [What is the use of @ModelAttribute annotation?](#18-what-is-the-use-of-modelattribute-annotation) |
| 19 | [How do you configure a view resolver in Spring MVC?](#19-how-do-you-configure-a-view-resolver-in-spring-mvc) |
| 20 | [What is the default scope of a Spring MVC controller?](#20-what-is-the-default-scope-of-a-spring-mvc-controller) |
| 21 | [How do you handle file uploads in Spring MVC?](#21-how-do-you-handle-file-uploads-in-spring-mvc) |
| 22 | [What is the difference between @RequestBody and @ResponseBody?](#22-what-is-the-difference-between-requestbody-and-responsebody) |
| 23 | [How do you configure a multipart resolver in Spring MVC?](#23-how-do-you-configure-a-multipart-resolver-in-spring-mvc) |
| 24 | [How do you enable Spring MVC annotations?](#24-how-do-you-enable-spring-mvc-annotations) |
| 25 | [What is the use of @SessionAttributes annotation?](#25-what-is-the-use-of-sessionattributes-annotation) |
### Level : Spring MVC Medium
| No. | Questions |
| --- | --------- |
| 26 | [How do you manage static resources in Spring MVC?](#26-how-do-you-manage-static-resources-in-spring-mvc) |
| 27 | [Explain the role of HandlerMapping in Spring MVC.](#27-explain-the-role-of-handlermapping-in-spring-mvc) |
| 28 | [What is the use of @InitBinder annotation?](#28-what-is-the-use-of-initbinder-annotation) |
| 29 | [How do you handle cross-origin requests in Spring MVC?](#29-how-do-you-handle-cross-origin-requests-in-spring-mvc) |
| 30 | [How do you configure internationalization in Spring MVC?](#30-how-do-you-configure-internationalization-in-spring-mvc) |
| 31 | [What is the role of Interceptor in Spring MVC?](#31-what-is-the-role-of-interceptor-in-spring-mvc) |
| 32 | [How do you implement security in a Spring MVC application?](#32-how-do-you-implement-security-in-a-spring-mvc-application) |
| 33 | [What is the difference between Spring MVC and Spring Boot?](#33-what-is-the-difference-between-spring-mvc-and-spring-boot) |
| 34 | [How do you configure a custom HandlerExceptionResolver in Spring MVC?](#34-how-do-you-configure-a-custom-handlerexceptionresolver-in-spring-mvc) |
| 35 | [What is the use of @CookieValue annotation?](#35-what-is-the-use-of-cookievalue-annotation) |
| 36 | [How do you configure message converters in Spring MVC?](#36-how-do-you-configure-message-converters-in-spring-mvc) |
| 37 | [What is the role of LocaleResolver in Spring MVC?](#37-what-is-the-role-of-localeresolver-in-spring-mvc) |
| 38 | [How do you enable CORS in Spring MVC?](#38-how-do-you-enable-cors-in-spring-mvc) |
| 39 | [What is the use of @RequestHeader annotation?](#39-what-is-the-use-of-requestheader-annotation) |
| 40 | [How do you implement RESTful web services using Spring MVC?](#40-how-do-you-implement-restful-web-services-using-spring-mvc) |
| 41 | [How do you integrate Spring MVC with Thymeleaf?](#41-how-do-you-integrate-spring-mvc-with-thymeleaf) |
| 42 | [What is the use of @ResponseStatus annotation?](#42-what-is-the-use-of-responsestatus-annotation) |
| 43 | [How do you configure a custom view resolver in Spring MVC?](#43-how-do-you-configure-a-custom-view-resolver-in-spring-mvc) |
| 44 | [What is the role of MultipartResolver in Spring MVC?](#44-what-is-the-role-of-multipartresolver-in-spring-mvc) |
| 45 | [How do you handle AJAX requests in Spring MVC?](#45-how-do-you-handle-ajax-requests-in-spring-mvc) |
| 46 | [What is the difference between @RequestMapping and @GetMapping?](#46-what-is-the-difference-between-requestmapping-and-getmapping) |
| 47 | [How do you configure a custom interceptor in Spring MVC?](#47-how-do-you-configure-a-custom-interceptor-in-spring-mvc) |
| 48 | [What is the use of @MatrixVariable annotation?](#48-what-is-the-use-of-matrixvariable-annotation) |
| 49 | [How do you configure a custom validator in Spring MVC?](#49-how-do-you-configure-a-custom-validator-in-spring-mvc) |
| 50 | [What is the role of FlashMap in Spring MVC?](#50-what-is-the-role-of-flashmap-in-spring-mvc) |
### Level : Spring MVC Hard
| No. | Questions |
| --- | --------- |
| 51 | [How do you implement asynchronous request processing in Spring MVC?](#51-how-do-you-implement-asynchronous-request-processing-in-spring-mvc) |
| 52 | [Explain the process of configuring Spring MVC with Java-based configuration.](#52-explain-the-process-of-configuring-spring-mvc-with-java-based-configuration) |
| 53 | [How do you configure a custom message converter in Spring MVC?](#53-how-do-you-configure-a-custom-message-converter-in-spring-mvc) |
| 54 | [What is the use of @ControllerAdvice annotation?](#54-what-is-the-use-of-controlleradvice-annotation) |
| 55 | [How do you handle WebSocket communication in a Spring MVC application?](#55-how-do-you-handle-websocket-communication-in-a-spring-mvc-application) |
| 56 | [How do you configure a custom locale resolver in Spring MVC?](#56-how-do-you-configure-a-custom-locale-resolver-in-spring-mvc) |
| 57 | [Explain the role of WebApplicationInitializer in Spring MVC.](#57-explain-the-role-of-webapplicationinitializer-in-spring-mvc) |
| 58 | [How do you implement file download functionality in Spring MVC?](#58-how-do-you-implement-file-download-functionality-in-spring-mvc) |
| 59 | [How do you configure a custom exception handler in Spring MVC?](#59-how-do-you-configure-a-custom-exception-handler-in-spring-mvc) |
| 60 | [What is the use of @RestControllerAdvice annotation?](#60-what-is-the-use-of-restcontrolleradvice-annotation) |
| 61 | [How do you integrate Spring MVC with Hibernate?](#61-how-do-you-integrate-spring-mvc-with-hibernate) |
| 62 | [Explain the process of handling multipart requests in Spring MVC.](#62-explain-the-process-of-handling-multipart-requests-in-spring-mvc) |
| 63 | [How do you configure a custom argument resolver in Spring MVC?](#63-how-do-you-configure-a-custom-argument-resolver-in-spring-mvc) |
| 64 | [What is the role of ContentNegotiationManager in Spring MVC?](#64-what-is-the-role-of-contentnegotiationmanager-in-spring-mvc) |
| 65 | [How do you implement HATEOAS in a Spring MVC application?](#65-how-do-you-implement-hateoas-in-a-spring-mvc-application) |
| 66 | [How do you configure a custom handler method return value handler in Spring MVC?](#66-how-do-you-configure-a-custom-handler-method-return-value-handler-in-spring-mvc) |
| 67 | [Explain the process of configuring Spring MVC with XML-based configuration.](#67-explain-the-process-of-configuring-spring-mvc-with-xml-based-configuration) |
| 68 | [How do you handle JSONP requests in Spring MVC?](#68-how-do-you-handle-jsonp-requests-in-spring-mvc) |
| 69 | [How do you configure a custom view in Spring MVC?](#69-how-do-you-configure-a-custom-view-in-spring-mvc) |
| 70 | [What is the role of HandlerAdapter in Spring MVC?](#70-what-is-the-role-of-handleradapter-in-spring-mvc) |
| 71 | [How do you configure a custom model attribute in Spring MVC?](#71-how-do-you-configure-a-custom-model-attribute-in-spring-mvc) |
| 72 | [How do you implement server-sent events (SSE) in a Spring MVC application?](#72-how-do-you-implement-server-sent-events-sse-in-a-spring-mvc-application) |
| 73 | [How do you configure a custom form handler in Spring MVC?](#73-how-do-you-configure-a-custom-form-handler-in-spring-mvc) |
| 74 | [What is the use of @JsonView annotation in Spring MVC?](#74-what-is-the-use-of-jsonview-annotation-in-spring-mvc) |
| 75 | [How do you implement OAuth2 authentication in a Spring MVC application?](#75-how-do-you-implement-oauth2-authentication-in-a-spring-mvc-application) |
## Spring Data JPA
### Table of Contents
### Level : Spring Data JPA Easy
| No. | Questions |
| --- | --------- |
| 1 | [What is Spring Data JPA?](#1-what-is-spring-data-jpa) |
| 2 | [What is the purpose of the `@Entity` annotation in JPA?](#2-what-is-the-purpose-of-the-entity-annotation-in-jpa) |
| 3 | [What is an EntityManager in JPA?](#3-what-is-an-entitymanager-in-jpa) |
| 4 | [What is the role of the `@Id` annotation in JPA?](#4-what-is-the-role-of-the-id-annotation-in-jpa) |
| 5 | [How do you define a primary key in a JPA entity?](#5-how-do-you-define-a-primary-key-in-a-jpa-entity) |
| 6 | [What is the difference between `findById` and `getOne` methods in JPA?](#6-what-is-the-difference-between-findbyid-and-getone-methods-in-jpa) |
| 7 | [What is the purpose of the `@Table` annotation in JPA?](#7-what-is-the-purpose-of-the-table-annotation-in-jpa) |
| 8 | [Explain the difference between `@Column` and `@JoinColumn`.](#8-explain-the-difference-between-column-and-joincolumn) |
| 9 | [What is the role of the `@GeneratedValue` annotation in JPA?](#9-what-is-the-role-of-the-generatedvalue-annotation-in-jpa) |
| 10 | [What is the default fetch type for `@OneToMany` and `@ManyToOne` relationships in JPA?](#10-what-is-the-default-fetch-type-for-onetomany-and-manytoone-relationships-in-jpa) |
| 11 | [How do you define a one-to-many relationship in JPA?](#11-how-do-you-define-a-one-to-many-relationship-in-jpa) |
| 12 | [What is a repository in Spring Data JPA?](#12-what-is-a-repository-in-spring-data-jpa) |
| 13 | [What is the purpose of the `@Repository` annotation in Spring Data JPA?](#13-what-is-the-purpose-of-the-repository-annotation-in-spring-data-jpa) |
| 14 | [How do you create a custom query in Spring Data JPA?](#14-how-do-you-create-a-custom-query-in-spring-data-jpa) |
| 15 | [What is the purpose of the `@Query` annotation in Spring Data JPA?](#15-what-is-the-purpose-of-the-query-annotation-in-spring-data-jpa) |
| 16 | [What is a JPQL?](#16-what-is-a-jpql) |
| 17 | [What is the difference between JPQL and SQL?](#17-what-is-the-difference-between-jpql-and-sql) |
| 18 | [What is the purpose of the `@Modifying` annotation in Spring Data JPA?](#18-what-is-the-purpose-of-the-modifying-annotation-in-spring-data-jpa) |
| 19 | [How do you handle transactions in Spring Data JPA?](#19-how-do-you-handle-transactions-in-spring-data-jpa) |
| 20 | [What is the `@Transactional` annotation used for in Spring Data JPA?](#20-what-is-the-transactional-annotation-used-for-in-spring-data-jpa) |
| 21 | [How do you paginate results in Spring Data JPA?](#21-how-do-you-paginate-results-in-spring-data-jpa) |
| 22 | [What is the `Pageable` interface in Spring Data JPA?](#22-what-is-the-pageable-interface-in-spring-data-jpa) |
| 23 | [What is the `Page` interface in Spring Data JPA?](#23-what-is-the-page-interface-in-spring-data-jpa) |
| 24 | [How do you sort results in Spring Data JPA?](#24-how-do-you-sort-results-in-spring-data-jpa) |
| 25 | [What is a derived query method in Spring Data JPA?](#25-what-is-a-derived-query-method-in-spring-data-jpa) |
| 26 | [What is the purpose of the `@NamedQuery` annotation in JPA?](#26-what-is-the-purpose-of-the-namedquery-annotation-in-jpa) |
| 27 | [What is an entity lifecycle in JPA?](#27-what-is-an-entity-lifecycle-in-jpa) |
| 28 | [What are the different states of an entity in JPA?](#28-what-are-the-different-states-of-an-entity-in-jpa) |
| 29 | [What is the purpose of the `@PrePersist` annotation in JPA?](#29-what-is-the-purpose-of-the-prepersist-annotation-in-jpa) |
| 30 | [What is the purpose of the `@PostPersist` annotation in JPA?](#30-what-is-the-purpose-of-the-postpersist-annotation-in-jpa) |
| 31 | [What is the purpose of the `@PreUpdate` annotation in JPA?](#31-what-is-the-purpose-of-the-preupdate-annotation-in-jpa) |
| 32 | [What is the purpose of the `@PostUpdate` annotation in JPA?](#32-what-is-the-purpose-of-the-postupdate-annotation-in-jpa) |
| 33 | [What is the purpose of the `@PreRemove` annotation in JPA?](#33-what-is-the-purpose-of-the-preremove-annotation-in-jpa) |
| 34 | [What is the purpose of the `@PostRemove` annotation in JPA?](#34-what-is-the-purpose-of-the-postremove-annotation-in-jpa) |
| 35 | [What is the purpose of the `@PostLoad` annotation in JPA?](#35-what-is-the-purpose-of-the-postload-annotation-in-jpa) |
### Level : Spring Data JPA Medium
| No. | Questions |
| --- | --------- |
| 36 | [Explain the different types of primary key generation strategies in JPA.](#36-explain-the-different-types-of-primary-key-generation-strategies-in-jpa) |
| 37 | [What is the difference between `@OneToMany` and `@ManyToMany` relationships in JPA?](#37-what-is-the-difference-between-onetomany-and-manytomany-relationships-in-jpa) |
| 38 | [How do you handle bi-directional relationships in JPA?](#38-how-do-you-handle-bi-directional-relationships-in-jpa) |
| 39 | [What is the `@MappedBy` attribute used for in JPA?](#39-what-is-the-mappedby-attribute-used-for-in-jpa) |
| 40 | [What is the purpose of the `@ElementCollection` annotation in JPA?](#40-what-is-the-purpose-of-the-elementcollection-annotation-in-jpa) |
| 41 | [How do you handle composite keys in JPA?](#41-how-do-you-handle-composite-keys-in-jpa) |
| 42 | [What is the `@Embeddable` annotation used for in JPA?](#42-what-is-the-embeddable-annotation-used-for-in-jpa) |
| 43 | [What is the purpose of the `@EmbeddedId` annotation in JPA?](#43-what-is-the-purpose-of-the-embeddedid-annotation-in-jpa) |
| 44 | [What is the role of the `@Inheritance` annotation in JPA?](#44-what-is-the-role-of-the-inheritance-annotation-in-jpa) |
| 45 | [Explain the different inheritance strategies in JPA.](#45-explain-the-different-inheritance-strategies-in-jpa) |
| 46 | [What is the purpose of the `@DiscriminatorColumn` annotation in JPA?](#46-what-is-the-purpose-of-the-discriminatorcolumn-annotation-in-jpa) |
| 47 | [What is the purpose of the `@DiscriminatorValue` annotation in JPA?](#47-what-is-the-purpose-of-the-discriminatorvalue-annotation-in-jpa) |
| 48 | [What is the purpose of the `@SecondaryTable` annotation in JPA?](#48-what-is-the-purpose-of-the-secondarytable-annotation-in-jpa) |
| 49 | [How do you define a native query in Spring Data JPA?](#49-how-do-you-define-a-native-query-in-spring-data-jpa) |
| 50 | [What is the purpose of the `@NamedNativeQuery` annotation in JPA?](#50-what-is-the-purpose-of-the-namednativequery-annotation-in-jpa) |
| 51 | [How do you handle optimistic locking in JPA?](#51-how-do-you-handle-optimistic-locking-in-jpa) |
| 52 | [What is the purpose of the `@Version` annotation in JPA?](#52-what-is-the-purpose-of-the-version-annotation-in-jpa) |
| 53 | [How do you handle pessimistic locking in JPA?](#53-how-do-you-handle-pessimistic-locking-in-jpa) |
| 54 | [What is the `EntityGraph` in JPA and how is it used?](#54-what-is-the-entitygraph-in-jpa-and-how-is-it-used) |
| 55 | [What are the different types of fetching strategies in JPA?](#55-what-are-the-different-types-of-fetching-strategies-in-jpa) |
| 56 | [What is the difference between eager and lazy loading in JPA?](#56-what-is-the-difference-between-eager-and-lazy-loading-in-jpa) |
| 57 | [How do you handle batch processing in Spring Data JPA?](#57-how-do-you-handle-batch-processing-in-spring-data-jpa) |
| 58 | [What is the purpose of the `@BatchSize` annotation in JPA?](#58-what-is-the-purpose-of-the-batchsize-annotation-in-jpa) |
| 59 | [How do you handle native SQL queries in Spring Data JPA?](#59-how-do-you-handle-native-sql-queries-in-spring-data-jpa) |
| 60 | [What is the purpose of the `@SqlResultSetMapping` annotation in JPA?](#60-what-is-the-purpose-of-the-sqlresultsetmapping-annotation-in-jpa) |
| 61 | [How do you handle auditing in Spring Data JPA?](#61-how-do-you-handle-auditing-in-spring-data-jpa) |
| 62 | [What is the purpose of the `@CreatedDate` annotation in JPA?](#62-what-is-the-purpose-of-the-createddate-annotation-in-jpa) |
| 63 | [What is the purpose of the `@LastModifiedDate` annotation in JPA?](#63-what-is-the-purpose-of-the-lastmodifieddate-annotation-in-jpa) |
| 64 | [What is the purpose of the `@CreatedBy` annotation in JPA?](#64-what-is-the-purpose-of-the-createdby-annotation-in-jpa) |
| 65 | [What is the purpose of the `@LastModifiedBy` annotation in JPA?](#65-what-is-the-purpose-of-the-lastmodifiedby-annotation-in-jpa) |
### Level : Spring Data JPA Hard
| No. | Questions |
| --- | --------- |
| 66 | [Explain the concept of entity graph in JPA and how it can be used to optimize performance.](#66-explain-the-concept-of-entity-graph-in-jpa-and-how-it-can-be-used-to-optimize-performance) |
| 67 | [How do you handle dynamic queries in Spring Data JPA?](#67-how-do-you-handle-dynamic-queries-in-spring-data-jpa) |
| 68 | [What is the role of the `Criteria API` in JPA?](#68-what-is-the-role-of-the-criteria-api-in-jpa) |
| 69 | [How do you use the `Criteria API` to create dynamic queries in JPA?](#69-how-do-you-use-the-criteria-api-to-create-dynamic-queries-in-jpa) |
| 70 | [What is the purpose of the `Specification` interface in Spring Data JPA?](#70-what-is-the-purpose-of-the-specification-interface-in-spring-data-jpa) |
| 71 | [How do you use the `Specification` interface to create dynamic queries in JPA?](#71-how-do-you-use-the-specification-interface-to-create-dynamic-queries-in-jpa) |
| 72 | [What is the purpose of the `@Cacheable` annotation in JPA?](#72-what-is-the-purpose-of-the-cacheable-annotation-in-jpa) |
| 73 | [How do you configure second-level cache in JPA?](#73-how-do-you-configure-second-level-cache-in-jpa) |
| 74 | [What is the difference between first-level and second-level cache in JPA?](#74-what-is-the-difference-between-first-level-and-second-level-cache-in-jpa) |
| 75 | [Explain the concept of dirty checking in JPA and how it works.](#75-explain-the-concept-of-dirty-checking-in-jpa-and-how-it-works) |
| 76 | [Explain the concept of cascade types in JPA and how they affect entity relationships.](#76-explain-the-concept-of-cascade-types-in-jpa-and-how-they-affect-entity-relationships) |
| 77 | [What are the different cascade types available in JPA and when would you use each?](#77-what-are-the-different-cascade-types-available-in-jpa-and-when-would-you-use-each) |
| 78 | [How do you handle orphan removal in JPA and what is the purpose of the `@OneToMany(orphanRemoval = true)` annotation?](#78-how-do-you-handle-orphan-removal-in-jpa-and-what-is-the-purpose-of-the-onetomanyorphanremoval--true-annotation) |
| 79 | [What are the different types of entity graphs (attribute node, subgraph) in JPA and how are they used?](#79-what-are-the-different-types-of-entity-graphs-attribute-node-subgraph-in-jpa-and-how-are-they-used) |
| 80 | [How do you optimize performance using Fetch Joins in JPQL?](#80-how-do-you-optimize-performance-using-fetch-joins-in-jpql) |
| 81 | [What is the N+1 select problem in JPA and how can it be mitigated?](#81-what-is-the-n1-select-problem-in-jpa-and-how-can-it-be-mitigated) |
| 82 | [Explain the purpose of the `@EntityListeners` annotation and how it is used in auditing.](#82-explain-the-purpose-of-the-entitylisteners-annotation-and-how-it-is-used-in-auditing) |
| 83 | [How do you handle multi-tenancy in JPA and what are the different strategies available?](#83-how-do-you-handle-multi-tenancy-in-jpa-and-what-are-the-different-strategies-available) |
| 84 | [How do you configure and use the `@SequenceGenerator` and `@TableGenerator` annotations in JPA?](#84-how-do-you-configure-and-use-the-sequencegenerator-and-tablegenerator-annotations-in-jpa) |
| 85 | [What is the purpose of the `@Converter` annotation in JPA and how do you use it to create custom converters?](#85-what-is-the-purpose-of-the-converter-annotation-in-jpa-and-how-do-you-use-it-to-create-custom-converters) |
| 86 | [How do you handle database migrations in a Spring Data JPA application?](#86-how-do-you-handle-database-migrations-in-a-spring-data-jpa-application) |
| 87 | [What are the key considerations when implementing a custom repository in Spring Data JPA?](#87-what-are-the-key-considerations-when-implementing-a-custom-repository-in-spring-data-jpa) |
| 88 | [How do you manage database connection pooling in a Spring Data JPA application?](#88-how-do-you-manage-database-connection-pooling-in-a-spring-data-jpa-application) |
| 89 | [What is the role of the `@SecondaryTable` annotation in JPA and how do you use it to map an entity to multiple tables?](#89-what-is-the-role-of-the-secondarytable-annotation-in-jpa-and-how-do-you-use-it-to-map-an-entity-to-multiple-tables) |
| 90 | [Explain the concept of `Entity Detachment` in JPA and how it affects the persistence context.](#90-explain-the-concept-of-entity-detachment-in-jpa-and-how-it-affects-the-persistence-context) |
| 91 | [How do you implement soft deletes in a Spring Data JPA application?](#91-how-do-you-implement-soft-deletes-in-a-spring-data-jpa-application) |
| 92 | [What are the pros and cons of using `EntityManager` directly versus using Spring Data JPA repositories?](#92-what-are-the-pros-and-cons-of-using-entitymanager-directly-versus-using-spring-data-jpa-repositories) |
| 93 | [How do you handle hierarchical data structures (e.g., trees, graphs) in JPA?](#93-how-do-you-handle-hierarchical-data-structures-eg-trees-graphs-in-jpa) |
| 94 | [Explain the concept of database sharding and how it can be implemented in a Spring Data JPA application.](#94-explain-the-concept-of-database-sharding-and-how-it-can-be-implemented-in-a-spring-data-jpa-application) |
| 95 | [What are the best practices for managing entity relationships and avoiding circular dependencies in JPA?](#95-what-are-the-best-practices-for-managing-entity-relationships-and-avoiding-circular-dependencies-in-jpa) |
| 96 | [How do you handle large data sets and pagination efficiently in a Spring Data JPA application?](#96-how-do-you-handle-large-data-sets-and-pagination-efficiently-in-a-spring-data-jpa-application) |
| 97 | [Explain the different types of joins (inner, outer, cross) in JPQL and provide examples of when to use each.](#97-explain-the-different-types-of-joins-inner-outer-cross-in-jpql-and-provide-examples-of-when-to-use-each) |
| 98 | [How do you handle custom exception handling and error codes in a Spring Data JPA application?](#98-how-do-you-handle-custom-exception-handling-and-error-codes-in-a-spring-data-jpa-application) |
| 99 | [What are the key differences between Hibernate and other JPA implementations like EclipseLink?](#99-what-are-the-key-differences-between-hibernate-and-other-jpa-implementations-like-eclipselink) |
| 100 | [How do you integrate Spring Data JPA with other Spring projects like Spring Batch or Spring Integration?](#100-how-do-you-integrate-spring-data-jpa-with-other-spring-projects-like-spring-batch-or-spring-integration) |
## Spring Security
### Table of Contents
### Level : Spring Security Easy
| No. | Questions |
| --- | --------- |
| 1 | [What is Spring Security?](#1-what-is-spring-security) |
| 2 | [How does Spring Security work?](#2-how-does-spring-security-work) |
| 3 | [What is the default login URL in Spring Security?](#3-what-is-the-default-login-url-in-spring-security) |
| 4 | [How do you configure HTTP Basic Authentication in Spring Security?](#4-how-do-you-configure-http-basic-authentication-in-spring-security) |
| 5 | [What is the purpose of the `@EnableWebSecurity` annotation?](#5-what-is-the-purpose-of-the-enablewebsecurity-annotation) |
| 6 | [How do you disable CSRF protection in Spring Security?](#6-how-do-you-disable-csrf-protection-in-spring-security) |
| 7 | [What is a `UserDetailsService`?](#7-what-is-a-userdetailsservice) |
| 8 | [How do you create a custom login form in Spring Security?](#8-how-do-you-create-a-custom-login-form-in-spring-security) |
| 9 | [Explain the role of `PasswordEncoder` in Spring Security.](#9-explain-the-role-of-passwordencoder-in-spring-security) |
| 10 | [How can you restrict access to a URL based on roles?](#10-how-can-you-restrict-access-to-a-url-based-on-roles) |
| 11 | [What is the purpose of the `SecurityContext`?](#11-what-is-the-purpose-of-the-securitycontext) |
| 12 | [How do you configure form-based authentication in Spring Security?](#12-how-do-you-configure-form-based-authentication-in-spring-security) |
| 13 | [What is the default username and password in Spring Security if none is provided?](#13-what-is-the-default-username-and-password-in-spring-security-if-none-is-provided) |
| 14 | [How do you implement logout functionality in Spring Security?](#14-how-do-you-implement-logout-functionality-in-spring-security) |
| 15 | [What is the difference between `@Secured` and `@PreAuthorize`?](#15-what-is-the-difference-between-secured-and-preauthorize) |
| 16 | [How do you secure a method in Spring Security?](#16-how-do-you-secure-a-method-in-spring-security) |
| 17 | [What is the role of the `AuthenticationManager`?](#17-what-is-the-role-of-the-authenticationmanager) |
| 18 | [How can you remember a user's login in Spring Security?](#18-how-can-you-remember-a-users-login-in-spring-security) |
| 19 | [How do you configure LDAP authentication in Spring Security?](#19-how-do-you-configure-ldap-authentication-in-spring-security) |
| 20 | [What is the purpose of the `UserDetails` interface?](#20-what-is-the-purpose-of-the-userdetails-interface) |
| 21 | [How do you create a custom `UserDetailsService`?](#21-how-do-you-create-a-custom-userdetailsservice) |
| 22 | [Explain the `GrantedAuthority` interface.](#22-explain-the-grantedauthority-interface) |
| 23 | [How do you configure HTTPS in Spring Security?](#23-how-do-you-configure-https-in-spring-security) |
| 24 | [What is the purpose of the `SecurityContextHolder`?](#24-what-is-the-purpose-of-the-securitycontextholder) |
| 25 | [How do you handle session fixation attacks in Spring Security?](#25-how-do-you-handle-session-fixation-attacks-in-spring-security) |
### Level : Spring Security Medium
| No. | Questions |
| --- | --------- |
| 26 | [How does Spring Security integrate with the Spring MVC framework?](#26-how-does-spring-security-integrate-with-the-spring-mvc-framework) |
| 27 | [Explain the concept of security filters in Spring Security.](#27-explain-the-concept-of-security-filters-in-spring-security) |
| 28 | [How do you configure multiple authentication providers in Spring Security?](#28-how-do-you-configure-multiple-authentication-providers-in-spring-security) |
| 29 | [How do you implement role-based access control in Spring Security?](#29-how-do-you-implement-role-based-access-control-in-spring-security) |
| 30 | [What is the purpose of the `FilterChainProxy`?](#30-what-is-the-purpose-of-the-filterchainproxy) |
| 31 | [How do you configure CORS in Spring Security?](#31-how-do-you-configure-cors-in-spring-security) |
| 32 | [Explain how to secure REST APIs with Spring Security.](#32-explain-how-to-secure-rest-apis-with-spring-security) |
| 33 | [How do you handle exceptions in Spring Security?](#33-how-do-you-handle-exceptions-in-spring-security) |
| 34 | [How do you customize the access denied page in Spring Security?](#34-how-do-you-customize-the-access-denied-page-in-spring-security) |
| 35 | [What is the role of `SecurityConfigurerAdapter`?](#35-what-is-the-role-of-securityconfigureradapter) |
| 36 | [How do you secure a Spring Boot application with Spring Security?](#36-how-do-you-secure-a-spring-boot-application-with-spring-security) |
| 37 | [Explain the `OAuth2` support in Spring Security.](#37-explain-the-oauth2-support-in-spring-security) |
| 38 | [How do you configure JWT authentication in Spring Security?](#38-how-do-you-configure-jwt-authentication-in-spring-security) |
| 39 | [What is the purpose of `HttpSecurity`?](#39-what-is-the-purpose-of-httpsecurity) |
| 40 | [How do you secure WebSocket connections in Spring Security?](#40-how-do-you-secure-websocket-connections-in-spring-security) |
| 41 | [How do you integrate Spring Security with Thymeleaf?](#41-how-do-you-integrate-spring-security-with-thymeleaf) |
| 42 | [Explain the purpose of `@WithMockUser` in Spring Security testing.](#42-explain-the-purpose-of-withmockuser-in-spring-security-testing) |
| 43 | [How do you configure a custom authentication provider in Spring Security?](#43-how-do-you-configure-a-custom-authentication-provider-in-spring-security) |
| 44 | [How do you handle CSRF tokens in AJAX requests with Spring Security?](#44-how-do-you-handle-csrf-tokens-in-ajax-requests-with-spring-security) |
| 45 | [What are the different types of authentication mechanisms supported by Spring Security?](#45-what-are-the-different-types-of-authentication-mechanisms-supported-by-spring-security) |
| 46 | [How do you implement two-factor authentication in Spring Security?](#46-how-do-you-implement-two-factor-authentication-in-spring-security) |
| 47 | [How do you configure security for a microservices architecture with Spring Security?](#47-how-do-you-configure-security-for-a-microservices-architecture-with-spring-security) |
| 48 | [Explain the concept of security expressions in Spring Security.](#48-explain-the-concept-of-security-expressions-in-spring-security) |
| 49 | [How do you implement single sign-on (SSO) with Spring Security?](#49-how-do-you-implement-single-sign-on-sso-with-spring-security) |
| 50 | [How do you perform security testing in a Spring Security application?](#50-how-do-you-perform-security-testing-in-a-spring-security-application) |
### Level : Spring Security Hard
| No. | Questions |
| --- | --------- |
| 51 | [Explain the internals of the `DelegatingFilterProxy`.](#51-explain-the-internals-of-the-delegatingfilterproxy) |
| 52 | [How does Spring Security handle authentication and authorization for reactive applications?](#52-how-does-spring-security-handle-authentication-and-authorization-for-reactive-applications) |
| 53 | [How do you implement custom security filters in Spring Security?](#53-how-do-you-implement-custom-security-filters-in-spring-security) |
| 54 | [Explain the `AbstractSecurityInterceptor` class.](#54-explain-the-abstractsecurityinterceptor-class) |
| 55 | [How do you integrate Spring Security with OAuth2 and OpenID Connect?](#55-how-do-you-integrate-spring-security-with-oauth2-and-openid-connect) |
| 56 | [How do you implement a custom `AccessDecisionManager`?](#56-how-do-you-implement-a-custom-accessdecisionmanager) |
| 57 | [How do you configure security for a Spring Cloud Gateway?](#57-how-do-you-configure-security-for-a-spring-cloud-gateway) |
| 58 | [Explain the `SecurityContextRepository` interface.](#58-explain-the-securitycontextrepository-interface) |
| 59 | [How do you implement attribute-based access control (ABAC) in Spring Security?](#59-how-do-you-implement-attribute-based-access-control-abac-in-spring-security) |
| 60 | [How do you integrate Spring Security with a third-party identity provider?](#60-how-do-you-integrate-spring-security-with-a-third-party-identity-provider) |
| 61 | [How do you handle cross-origin resource sharing (CORS) in a Spring Security application?](#61-how-do-you-handle-cross-origin-resource-sharing-cors-in-a-spring-security-application) |
| 62 | [Explain the concept of AOP-based method security in Spring Security.](#62-explain-the-concept-of-aop-based-method-security-in-spring-security) |
| 63 | [How do you configure security for a multi-tenant application in Spring Security?](#63-how-do-you-configure-security-for-a-multi-tenant-application-in-spring-security) |
| 64 | [How do you implement custom token-based authentication in Spring Security?](#64-how-do-you-implement-custom-token-based-authentication-in-spring-security) |
| 65 | [Explain the `SecurityExpressionHandler` interface.](#65-explain-the-securityexpressionhandler-interface) |
| 66 | [How do you handle password reset functionality in Spring Security?](#66-how-do-you-handle-password-reset-functionality-in-spring-security) |
| 67 | [How do you secure a Spring WebFlux application with Spring Security?](#67-how-do-you-secure-a-spring-webflux-application-with-spring-security) |
| 68 | [Explain the `ReactiveAuthenticationManager` interface.](#68-explain-the-reactiveauthenticationmanager-interface) |
| 69 | [How do you implement security auditing in Spring Security?](#69-how-do-you-implement-security-auditing-in-spring-security) |
| 70 | [How do you secure a Spring Boot Admin server with Spring Security?](#70-how-do-you-secure-a-spring-boot-admin-server-with-spring-security) |
| 71 | [Explain the `SecurityEvaluationContextExtension` class.](#71-explain-the-securityevaluationcontextextension-class) |
| 72 | [How do you configure security for a GraphQL API with Spring Security?](#72-how-do-you-configure-security-for-a-graphql-api-with-spring-security) |
| 73 | [How do you implement security for a server-sent events (SSE) endpoint in Spring Security?](#73-how-do-you-implement-security-for-a-server-sent-events-sse-endpoint-in-spring-security) |
| 74 | [Explain the `JwtAccessTokenConverter` class.](#74-explain-the-jwtaccesstokenconverter-class) |
| 75 | [How do you handle security for a batch processing application with Spring Security?](#75-how-do-you-handle-security-for-a-batch-processing-application-with-spring-security) |
## Spring AOP
### Table of Contents
### Level : Spring AOP Easy
| No. | Questions |
| --- | --------- |
| 1 | [What does AOP stand for in Spring?](#1-what-does-aop-stand-for-in-spring) |
| 2 | [What are the key concepts of AOP?](#2-what-are-the-key-concepts-of-aop) |
| 3 | [What is a cross-cutting concern? Can you give an example?](#3-what-is-a-cross-cutting-concern-can-you-give-an-example) |
| 4 | [What is a join point?](#4-what-is-a-join-point) |
| 5 | [What is a pointcut?](#5-what-is-a-pointcut) |
| 6 | [What is an advice?](#6-what-is-an-advice) |
| 7 | [What are the different types of advice in Spring AOP?](#7-what-are-the-different-types-of-advice-in-spring-aop) |
| 8 | [What is an aspect?](#8-what-is-an-aspect) |
| 9 | [How do you define an aspect in Spring AOP?](#9-how-do-you-define-an-aspect-in-spring-aop) |
| 10 | [What is a proxy in Spring AOP?](#10-what-is-a-proxy-in-spring-aop) |
| 11 | [What is weaving in the context of AOP?](#11-what-is-weaving-in-the-context-of-aop) |
| 12 | [What is the difference between Spring AOP and AspectJ?](#12-what-is-the-difference-between-spring-aop-and-aspectj) |
| 13 | [How do you enable AOP in a Spring application?](#13-how-do-you-enable-aop-in-a-spring-application) |
| 14 | [What is @Aspect annotation used for?](#14-what-is-aspect-annotation-used-for) |
| 15 | [What is @Pointcut annotation used for?](#15-what-is-pointcut-annotation-used-for) |
| 16 | [What is the use of @Before annotation?](#16-what-is-the-use-of-before-annotation) |
| 17 | [What is the use of @After annotation?](#17-what-is-the-use-of-after-annotation) |
| 18 | [What is the use of @AfterReturning annotation?](#18-what-is-the-use-of-afterreturning-annotation) |
| 19 | [What is the use of @AfterThrowing annotation?](#19-what-is-the-use-of-afterthrowing-annotation) |
| 20 | [What is the use of @Around annotation?](#20-what-is-the-use-of-around-annotation) |
| 21 | [How do you define a pointcut expression?](#21-how-do-you-define-a-pointcut-expression) |
| 22 | [What is the purpose of JoinPoint interface in Spring AOP?](#22-what-is-the-purpose-of-joinpoint-interface-in-spring-aop) |
| 23 | [Can you use Spring AOP with Spring Boot?](#23-can-you-use-spring-aop-with-spring-boot) |
| 24 | [How would you exclude a method from being advised?](#24-how-would-you-exclude-a-method-from-being-advised) |
| 25 | [What are the limitations of Spring AOP?](#25-what-are-the-limitations-of-spring-aop) |
### Level : Spring AOP Medium
| No. | Questions |
| --- | --------- |
| 26 | [How does Spring AOP work internally?](#26-how-does-spring-aop-work-internally) |
| 27 | [What is the difference between static and dynamic weaving?](#27-what-is-the-difference-between-static-and-dynamic-weaving) |
| 28 | [What is the difference between compile-time and load-time weaving?](#28-what-is-the-difference-between-compile-time-and-load-time-weaving) |
| 29 | [How do you implement a custom annotation for AOP?](#29-how-do-you-implement-a-custom-annotation-for-aop) |
| 30 | [How can you control the order of multiple aspects?](#30-how-can-you-control-the-order-of-multiple-aspects) |
| 31 | [How do you pass parameters to advice methods?](#31-how-do-you-pass-parameters-to-advice-methods) |
| 32 | [Can you access the return value in @AfterReturning advice?](#32-can-you-access-the-return-value-in-afterreturning-advice) |
| 33 | [What is the use of ProceedingJoinPoint in @Around advice?](#33-what-is-the-use-of-proceedingjoinpoint-in-around-advice) |
| 34 | [How do you handle exceptions in AOP?](#34-how-do-you-handle-exceptions-in-aop) |
| 35 | [How can you apply AOP to specific beans?](#35-how-can-you-apply-aop-to-specific-beans) |
| 36 | [How do you define multiple pointcuts in a single aspect?](#36-how-do-you-define-multiple-pointcuts-in-a-single-aspect) |
| 37 | [Can you use AOP with non-Spring managed beans?](#37-can-you-use-aop-with-non-spring-managed-beans) |
| 38 | [What is the use of @DeclareParents annotation?](#38-what-is-the-use-of-declareparents-annotation) |
| 39 | [How do you test AOP functionality?](#39-how-do-you-test-aop-functionality) |
| 40 | [Can you use AOP to modify method arguments?](#40-can-you-use-aop-to-modify-method-arguments) |
| 41 | [How can you measure method execution time using AOP?](#41-how-can-you-measure-method-execution-time-using-aop) |
| 42 | [How do you disable AOP for a specific environment?](#42-how-do-you-disable-aop-for-a-specific-environment) |
| 43 | [How do you combine multiple pointcut expressions?](#43-how-do-you-combine-multiple-pointcut-expressions) |
| 44 | [What is the use of @EnableAspectJAutoProxy annotation?](#44-what-is-the-use-of-enableaspectjautoproxy-annotation) |
| 45 | [How do you apply AOP to private methods?](#45-how-do-you-apply-aop-to-private-methods) |
| 46 | [How do you use AOP to manage transactions?](#46-how-do-you-use-aop-to-manage-transactions) |
| 47 | [What is the difference between @Aspect and @Component annotations?](#47-what-is-the-difference-between-aspect-and-component-annotations) |
| 48 | [How do you implement a logging aspect?](#48-how-do-you-implement-a-logging-aspect) |
| 49 | [How do you use AOP to handle security concerns?](#49-how-do-you-use-aop-to-handle-security-concerns) |
| 50 | [How do you use AOP to handle caching?](#50-how-do-you-use-aop-to-handle-caching) |
### Level : Spring AOP Hard
| No. | Questions |
| --- | --------- |
| 51 | [How does Spring AOP integrate with AspectJ?](#51-how-does-spring-aop-integrate-with-aspectj) |
| 52 | [What are AspectJ annotations and how are they different from Spring AOP annotations?](#52-what-are-aspectj-annotations-and-how-are-they-different-from-spring-aop-annotations) |
| 53 | [How do you perform load-time weaving with AspectJ in a Spring application?](#53-how-do-you-perform-load-time-weaving-with-aspectj-in-a-spring-application) |
| 54 | [What is the @AspectJ style of declaring aspects?](#54-what-is-the-aspectj-style-of-declaring-aspects) |
| 55 | [How do you use @Configurable annotation in AspectJ?](#55-how-do-you-use-configurable-annotation-in-aspectj) |
| 56 | [How do you implement aspect precedence in AspectJ?](#56-how-do-you-implement-aspect-precedence-in-aspectj) |
| 57 | [How do you use @DeclareError and @DeclareWarning annotations in AspectJ?](#57-how-do-you-use-declareerror-and-declarewarning-annotations-in-aspectj) |
| 58 | [How do you use AOP with asynchronous methods?](#58-how-do-you-use-aop-with-asynchronous-methods) |
| 59 | [How do you use AOP to implement a retry mechanism?](#59-how-do-you-use-aop-to-implement-a-retry-mechanism) |
| 60 | [How do you manage circular dependencies in AOP?](#60-how-do-you-manage-circular-dependencies-in-aop) |
| 61 | [How do you use AOP to enforce coding standards?](#61-how-do-you-use-aop-to-enforce-coding-standards) |
| 62 | [How do you use AOP for monitoring and profiling?](#62-how-do-you-use-aop-for-monitoring-and-profiling) |
| 63 | [How do you use AOP to implement a feature toggle?](#63-how-do-you-use-aop-to-implement-a-feature-toggle) |
| 64 | [How do you use AOP to implement a rate limiter?](#64-how-do-you-use-aop-to-implement-a-rate-limiter) |
| 65 | [How do you use AOP to implement a circuit breaker?](#65-how-do-you-use-aop-to-implement-a-circuit-breaker) |
| 66 | [How do you use AOP to implement dependency injection?](#66-how-do-you-use-aop-to-implement-dependency-injection) |
| 67 | [What is the use of @AspectJAutoProxyCreator?](#67-what-is-the-use-of-aspectjautoproxycreator) |
| 68 | [How do you create a custom pointcut expression?](#68-how-do-you-create-a-custom-pointcut-expression) |
| 69 | [How do you handle concurrency issues in AOP?](#69-how-do-you-handle-concurrency-issues-in-aop) |
| 70 | [How do you use AOP for dynamic proxy creation?](#70-how-do-you-use-aop-for-dynamic-proxy-creation) |
| 71 | [How do you use AOP to handle resource management?](#71-how-do-you-use-aop-to-handle-resource-management) |
| 72 | [How do you use AOP to implement data validation?](#72-how-do-you-use-aop-to-implement-data-validation) |
| 73 | [How do you use AOP to handle method chaining?](#73-how-do-you-use-aop-to-handle-method-chaining) |
| 74 | [How do you optimize AOP performance?](#74-how-do-you-optimize-aop-performance) |
| 75 | [How do you debug AOP issues in a Spring application?](#75-how-do-you-debug-aop-issues-in-a-spring-application) |
## Spring Cloud
### Table of Contents
### Level : Spring Cloud Easy
| No. | Questions |
| --- | --------- |
| 1 | [What is Spring Cloud, and how is it different from Spring Boot?](#1-what-is-spring-cloud-and-how-is-it-different-from-spring-boot) |
| 2 | [Explain the concept of microservices.](#2-explain-the-concept-of-microservices) |
| 3 | [What is Spring Cloud Config, and how does it work?](#3-what-is-spring-cloud-config-and-how-does-it-work) |
| 4 | [How do you use Spring Cloud Config Server to manage configuration for microservices?](#4-how-do-you-use-spring-cloud-config-server-to-manage-configuration-for-microservices) |
| 5 | [What is the role of Eureka in Spring Cloud?](#5-what-is-the-role-of-eureka-in-spring-cloud) |
| 6 | [How do you register a service with Eureka?](#6-how-do-you-register-a-service-with-eureka) |
| 7 | [What is Zuul, and how does it work in Spring Cloud?](#7-what-is-zuul-and-how-does-it-work-in-spring-cloud) |
| 8 | [How do you implement a Zuul API Gateway?](#8-how-do-you-implement-a-zuul-api-gateway) |
| 9 | [What is Spring Cloud Feign, and what are its advantages?](#9-what-is-spring-cloud-feign-and-what-are-its-advantages) |
| 10 | [How do you use Feign clients to call other microservices?](#10-how-do-you-use-feign-clients-to-call-other-microservices) |
| 11 | [What is Hystrix, and how does it help in fault tolerance?](#11-what-is-hystrix-and-how-does-it-help-in-fault-tolerance) |
| 12 | [How do you implement Hystrix in a Spring Cloud application?](#12-how-do-you-implement-hystrix-in-a-spring-cloud-application) |
| 13 | [Explain the circuit breaker pattern and its benefits.](#13-explain-the-circuit-breaker-pattern-and-its-benefits) |
| 14 | [What is Spring Cloud Sleuth, and how does it help in distributed tracing?](#14-what-is-spring-cloud-sleuth-and-how-does-it-help-in-distributed-tracing) |
| 15 | [How do you enable and use Spring Cloud Sleuth?](#15-how-do-you-enable-and-use-spring-cloud-sleuth) |
| 16 | [What is Spring Cloud Bus, and how does it work?](#16-what-is-spring-cloud-bus-and-how-does-it-work) |
| 17 | [How do you use Spring Cloud Bus to propagate configuration changes?](#17-how-do-you-use-spring-cloud-bus-to-propagate-configuration-changes) |
| 18 | [What is a Config Server, and how do you set it up?](#18-what-is-a-config-server-and-how-do-you-set-it-up) |
| 19 | [How do you secure a Spring Cloud Config Server?](#19-how-do-you-secure-a-spring-cloud-config-server) |
| 20 | [What is the purpose of Spring Cloud Stream?](#20-what-is-the-purpose-of-spring-cloud-stream) |
| 21 | [How do you use Spring Cloud Stream to build event-driven microservices?](#21-how-do-you-use-spring-cloud-stream-to-build-event-driven-microservices) |
| 22 | [What is Ribbon, and how does it achieve client-side load balancing?](#22-what-is-ribbon-and-how-does-it-achieve-client-side-load-balancing) |
| 23 | [How do you integrate Ribbon with Eureka?](#23-how-do-you-integrate-ribbon-with-eureka) |
| 24 | [What is Spring Cloud Gateway, and how is it different from Zuul?](#24-what-is-spring-cloud-gateway-and-how-is-it-different-from-zuul) |
| 25 | [How do you implement rate limiting in Spring Cloud Gateway?](#25-how-do-you-implement-rate-limiting-in-spring-cloud-gateway) |
### Table of Contents
### Level : Spring Cloud Medium
| No. | Questions |
| --- | --------- |
| 26 | [How do you handle configuration changes dynamically in Spring Cloud?](#26-how-do-you-handle-configuration-changes-dynamically-in-spring-cloud) |
| 27 | [What are the different ways to configure a Spring Cloud application?](#27-what-are-the-different-ways-to-configure-a-spring-cloud-application) |
| 28 | [How do you manage secrets and sensitive data in Spring Cloud Config?](#28-how-do-you-manage-secrets-and-sensitive-data-in-spring-cloud-config) |
| 29 | [Explain the differences between client-side and server-side load balancing.](#29-explain-the-differences-between-client-side-and-server-side-load-balancing) |
| 30 | [How do you implement a custom load-balancing strategy with Ribbon?](#30-how-do-you-implement-a-custom-load-balancing-strategy-with-ribbon) |
| 31 | [Describe the fallback mechanism in Hystrix.](#31-describe-the-fallback-mechanism-in-hystrix) |
| 32 | [How do you configure a global fallback method in Hystrix?](#32-how-do-you-configure-a-global-fallback-method-in-hystrix) |
| 33 | [What is the difference between a Hystrix command and a Hystrix observable command?](#33-what-is-the-difference-between-a-hystrix-command-and-a-hystrix-observable-command) |
| 34 | [How do you monitor Hystrix metrics?](#34-how-do-you-monitor-hystrix-metrics) |
| 35 | [What are Spring Cloud Sleuth's span and trace IDs?](#35-what-are-spring-cloud-sleuths-span-and-trace-ids) |
| 36 | [How do you propagate tracing information across microservices with Spring Cloud Sleuth?](#36-how-do-you-propagate-tracing-information-across-microservices-with-spring-cloud-sleuth) |
| 37 | [Explain the role of Zipkin in distributed tracing.](#37-explain-the-role-of-zipkin-in-distributed-tracing) |
| 38 | [How do you integrate Spring Cloud Sleuth with Zipkin?](#38-how-do-you-integrate-spring-cloud-sleuth-with-zipkin) |
| 39 | [What are the advantages of using Spring Cloud Stream over traditional messaging?](#39-what-are-the-advantages-of-using-spring-cloud-stream-over-traditional-messaging) |
| 40 | [How do you implement a custom binder in Spring Cloud Stream?](#40-how-do-you-implement-a-custom-binder-in-spring-cloud-stream) |
| 41 | [What is the difference between @StreamListener and @EnableBinding?](#41-what-is-the-difference-between-streamlistener-and-enablebinding) |
| 42 | [How do you achieve data consistency in microservices using Spring Cloud Stream?](#42-how-do-you-achieve-data-consistency-in-microservices-using-spring-cloud-stream) |
| 43 | [Explain the difference between Spring Cloud Bus and Spring Cloud Stream.](#43-explain-the-difference-between-spring-cloud-bus-and-spring-cloud-stream) |
| 44 | [How do you implement distributed transactions in Spring Cloud?](#44-how-do-you-implement-distributed-transactions-in-spring-cloud) |
| 45 | [Describe the role of Spring Cloud Consul.](#45-describe-the-role-of-spring-cloud-consul) |
| 46 | [How do you use Consul for service discovery and configuration management?](#46-how-do-you-use-consul-for-service-discovery-and-configuration-management) |
| 47 | [What is Spring Cloud Kubernetes, and how does it help in deploying microservices to Kubernetes?](#47-what-is-spring-cloud-kubernetes-and-how-does-it-help-in-deploying-microservices-to-kubernetes) |
| 48 | [How do you configure Spring Cloud applications for Kubernetes?](#48-how-do-you-configure-spring-cloud-applications-for-kubernetes) |
| 49 | [Explain the concept of service mesh and its benefits.](#49-explain-the-concept-of-service-mesh-and-its-benefits) |
| 50 | [How do you integrate Spring Cloud applications with Istio?](#50-how-do-you-integrate-spring-cloud-applications-with-istio) |
| 51 | [What is the difference between Spring Cloud Gateway and Spring Cloud Zuul?](#51-what-is-the-difference-between-spring-cloud-gateway-and-spring-cloud-zuul) |
| 52 | [How do you implement security in Spring Cloud Gateway?](#52-how-do-you-implement-security-in-spring-cloud-gateway) |
| 53 | [Describe the role of OAuth2 in securing microservices.](#53-describe-the-role-of-oauth2-in-securing-microservices) |
| 54 | [How do you integrate Spring Security OAuth2 with Spring Cloud Gateway?](#54-how-do-you-integrate-spring-security-oauth2-with-spring-cloud-gateway) |
| 55 | [Explain how to use Spring Cloud Contract for consumer-driven contracts.](#55-explain-how-to-use-spring-cloud-contract-for-consumer-driven-contracts) |
### Table of Contents
### Level : Spring Cloud Hard
| No. | Questions |
| --- | --------- |
| 56 | [How do you implement a distributed caching strategy in Spring Cloud?](#56-how-do-you-implement-a-distributed-caching-strategy-in-spring-cloud) |
| 57 | [Explain the CAP theorem and its relevance to Spring Cloud applications.](#57-explain-the-cap-theorem-and-its-relevance-to-spring-cloud-applications) |
| 58 | [How do you handle eventual consistency in microservices?](#58-how-do-you-handle-eventual-consistency-in-microservices) |
| 59 | [What are the challenges of using microservices, and how does Spring Cloud address them?](#59-what-are-the-challenges-of-using-microservices-and-how-does-spring-cloud-address-them) |
| 60 | [How do you implement a custom Zuul filter?](#60-how-do-you-implement-a-custom-zuul-filter) |
| 61 | [What are the different types of Zuul filters, and how do they work?](#61-what-are-the-different-types-of-zuul-filters-and-how-do-they-work) |
| 62 | [How do you implement a custom plugin for Spring Cloud Gateway?](#62-how-do-you-implement-a-custom-plugin-for-spring-cloud-gateway) |
| 63 | [Explain the importance of service registry in microservices architecture.](#63-explain-the-importance-of-service-registry-in-microservices-architecture) |
| 64 | [How do you implement a custom service registry with Spring Cloud?](#64-how-do-you-implement-a-custom-service-registry-with-spring-cloud) |
| 65 | [Describe a scenario where you would use Spring Cloud Sleuth without Zipkin.](#65-describe-a-scenario-where-you-would-use-spring-cloud-sleuth-without-zipkin) |
| 66 | [How do you monitor and troubleshoot performance issues in a Spring Cloud application?](#66-how-do-you-monitor-and-troubleshoot-performance-issues-in-a-spring-cloud-application) |
| 67 | [What is the role of Prometheus and Grafana in monitoring Spring Cloud applications?](#67-what-is-the-role-of-prometheus-and-grafana-in-monitoring-spring-cloud-applications) |
| 68 | [How do you configure Spring Cloud applications for high availability?](#68-how-do-you-configure-spring-cloud-applications-for-high-availability) |
| 69 | [Explain the concept of blue-green deployment and how to implement it with Spring Cloud.](#69-explain-the-concept-of-blue-green-deployment-and-how-to-implement-it-with-spring-cloud) |
| 70 | [How do you handle versioning of microservices in Spring Cloud?](#70-how-do-you-handle-versioning-of-microservices-in-spring-cloud) |
| 71 | [What is Canary release, and how do you implement it with Spring Cloud?](#71-what-is-canary-release-and-how-do-you-implement-it-with-spring-cloud) |
| 72 | [How do you implement a global error handling strategy in Spring Cloud Gateway?](#72-how-do-you-implement-a-global-error-handling-strategy-in-spring-cloud-gateway) |
| 73 | [Explain the importance of observability in microservices and how Spring Cloud helps achieve it.](#73-explain-the-importance-of-observability-in-microservices-and-how-spring-cloud-helps-achieve-it) |
| 74 | [How do you implement distributed logging in Spring Cloud applications?](#74-how-do-you-implement-distributed-logging-in-spring-cloud-applications) |
| 75 | [Describe a complex use case where you combined multiple Spring Cloud components to solve a problem.](#75-describe-a-complex-use-case-where-you-combined-multiple-spring-cloud-components-to-solve-a-problem) |
## Spring Batch
### Table of Contents
| No. | Questions |
| --- | --------- |
| 1 | [What is Spring Batch and why is it used?](#1-what-is-spring-batch-and-why-is-it-used) |
| 2 | [Describe the architecture of Spring Batch.](#2-describe-the-architecture-of-spring-batch) |
| 3 | [What are the main components of a Spring Batch job?](#3-what-are-the-main-components-of-a-spring-batch-job) |
| 4 | [Explain the concept of a Job and a Step in Spring Batch.](#4-explain-the-concept-of-a-job-and-a-step-in-spring-batch) |
| 5 | [What is a JobRepository in Spring Batch?](#5-what-is-a-jobrepository-in-spring-batch) |
| 6 | [How is transaction management handled in Spring Batch?](#6-how-is-transaction-management-handled-in-spring-batch) |
| 7 | [What is a JobLauncher and how does it work?](#7-what-is-a-joblauncher-and-how-does-it-work) |
| 8 | [Explain the role of JobParameters in Spring Batch.](#8-explain-the-role-of-jobparameters-in-spring-batch) |
| 9 | [What is the difference between a Tasklet and a Chunk-oriented processing in Spring Batch?](#9-what-is-the-difference-between-a-tasklet-and-a-chunk-oriented-processing-in-spring-batch) |
| 10 | [How can you configure a Step in Spring Batch?](#10-how-can-you-configure-a-step-in-spring-batch) |
| 11 | [What are ItemReader, ItemProcessor, and ItemWriter in Spring Batch?](#11-what-are-itemreader-itemprocessor-and-itemwriter-in-spring-batch) |
| 12 | [How do you handle job execution states in Spring Batch?](#12-how-do-you-handle-job-execution-states-in-spring-batch) |
| 13 | [What is a JobExecutionListener and how is it used?](#13-what-is-a-jobexecutionlistener-and-how-is-it-used) |
| 14 | [How do you handle job restarts in Spring Batch?](#14-how-do-you-handle-job-restarts-in-spring-batch) |
| 15 | [What are the different ways to configure Spring Batch jobs?](#15-what-are-the-different-ways-to-configure-spring-batch-jobs) |
| 16 | [How do you implement skip and retry logic in Spring Batch?](#16-how-do-you-implement-skip-and-retry-logic-in-spring-batch) |
| 17 | [What are the different job status and exit status codes in Spring Batch?](#17-what-are-the-different-job-status-and-exit-status-codes-in-spring-batch) |
| 18 | [Explain the concept of JobInstance and JobExecution in Spring Batch.](#18-explain-the-concept-of-jobinstance-and-jobexecution-in-spring-batch) |
| 19 | [How do you manage job concurrency in Spring Batch?](#19-how-do-you-manage-job-concurrency-in-spring-batch) |
| 20 | [What is the role of the StepExecutionListener?](#20-what-is-the-role-of-the-stepexecutionlistener) |
| 21 | [How would you configure and use a FlatFileItemReader in Spring Batch?](#21-how-would-you-configure-and-use-a-flatfileitemreader-in-spring-batch) |
| 22 | [How can you process XML files using Spring Batch?](#22-how-can-you-process-xml-files-using-spring-batch) |
| 23 | [Describe how to handle exceptions in Spring Batch.](#23-describe-how-to-handle-exceptions-in-spring-batch) |
| 24 | [Explain the role of the ExecutionContext in Spring Batch.](#24-explain-the-role-of-the-executioncontext-in-spring-batch) |
| 25 | [How do you integrate Spring Batch with Spring Boot?](#25-how-do-you-integrate-spring-batch-with-spring-boot) |
| 26 | [What are the benefits of using Spring Batch with Spring Boot?](#26-what-are-the-benefits-of-using-spring-batch-with-spring-boot) |
| 27 | [How can you schedule Spring Batch jobs?](#27-how-can-you-schedule-spring-batch-jobs) |
| 28 | [What are the best practices for designing Spring Batch jobs?](#28-what-are-the-best-practices-for-designing-spring-batch-jobs) |
| 29 | [How do you monitor and manage Spring Batch jobs?](#29-how-do-you-monitor-and-manage-spring-batch-jobs) |
| 30 | [Explain the role of the JobOperator in Spring Batch.](#30-explain-the-role-of-the-joboperator-in-spring-batch) |
| 31 | [How can you partition a Spring Batch job?](#31-how-can-you-partition-a-spring-batch-job) |
| 32 | [What is a CompositeItemProcessor and how is it used?](#32-what-is-a-compositeitemprocessor-and-how-is-it-used) |
| 33 | [How do you implement a multi-threaded Step in Spring Batch?](#33-how-do-you-implement-a-multi-threaded-step-in-spring-batch) |
| 34 | [What is the purpose of the Spring Batch Admin?](#34-what-is-the-purpose-of-the-spring-batch-admin) |
| 35 | [How do you use the Spring Batch integration with Spring Cloud Data Flow?](#35-how-do-you-use-the-spring-batch-integration-with-spring-cloud-data-flow) |
| 36 | [Explain the importance of the Spring Batch namespace configuration.](#36-explain-the-importance-of-the-spring-batch-namespace-configuration) |
| 37 | [What is a StepScope and how is it used in Spring Batch?](#37-what-is-a-stepscope-and-how-is-it-used-in-spring-batch) |
| 38 | [Describe how to implement a custom ItemReader.](#38-describe-how-to-implement-a-custom-itemreader) |
| 39 | [How do you handle large data sets in Spring Batch?](#39-how-do-you-handle-large-data-sets-in-spring-batch) |
| 40 | [How can you process database records using Spring Batch?](#40-how-can-you-process-database-records-using-spring-batch) |
| 41 | [What is a StaxEventItemReader and how is it used?](#41-what-is-a-staxeventitemreader-and-how-is-it-used) |
| 42 | [How do you manage job dependencies in Spring Batch?](#42-how-do-you-manage-job-dependencies-in-spring-batch) |
| 43 | [Explain the concept of job parameters incrementer.](#43-explain-the-concept-of-job-parameters-incrementer) |
| 44 | [How can you customize the JobLauncher?](#44-how-can-you-customize-the-joblauncher) |
| 45 | [What are the different ways to stop a running job in Spring Batch?](#45-what-are-the-different-ways-to-stop-a-running-job-in-spring-batch) |
| 46 | [How do you implement conditional flow in a Spring Batch job?](#46-how-do-you-implement-conditional-flow-in-a-spring-batch-job) |
| 47 | [Describe the use of the SimpleJobLauncher.](#47-describe-the-use-of-the-simplejoblauncher) |
| 48 | [How can you handle job execution failures in Spring Batch?](#48-how-can-you-handle-job-execution-failures-in-spring-batch) |
| 49 | [How do you use annotations in Spring Batch configuration?](#49-how-do-you-use-annotations-in-spring-batch-configuration) |
| 50 | [What are the core interfaces provided by Spring Batch?](#50-what-are-the-core-interfaces-provided-by-spring-batch) |
## Spring Integration
### Table of Contents
| No. | Questions |
| --- | --------- |
| 1 | [What is Spring Integration? Explain the purpose and use cases of Spring Integration.](#1-what-is-spring-integration-explain-the-purpose-and-use-cases-of-spring-integration) |
| 2 | [What are the main components of Spring Integration?](#2-what-are-the-main-components-of-spring-integration) |
| 3 | [How does Spring Integration support messaging systems?](#3-how-does-spring-integration-support-messaging-systems) |
| 4 | [Explain the concept of a Message in Spring Integration.](#4-explain-the-concept-of-a-message-in-spring-integration) |
| 5 | [What is a Message Channel in Spring Integration?](#5-what-is-a-message-channel-in-spring-integration) |
| 6 | [Differentiate between Direct Channel and Queue Channel.](#6-differentiate-between-direct-channel-and-queue-channel) |
| 7 | [What are Message Endpoints?](#7-what-are-message-endpoints) |
| 8 | [Explain the role of Message Transformers in Spring Integration.](#8-explain-the-role-of-message-transformers-in-spring-integration) |
| 9 | [What are Message Routers?](#9-what-are-message-routers) |
| 10 | [How do you configure a Message Filter in Spring Integration?](#10-how-do-you-configure-a-message-filter-in-spring-integration) |
| 11 | [What is a Message Splitter?](#11-what-is-a-message-splitter) |
| 12 | [Describe the use of a Message Aggregator.](#12-describe-the-use-of-a-message-aggregator) |
| 13 | [How does Spring Integration support error handling?](#13-how-does-spring-integration-support-error-handling) |
| 14 | [What is a Pollable Channel in Spring Integration?](#14-what-is-a-pollable-channel-in-spring-integration) |
| 15 | [Explain the concept of a Channel Adapter.](#15-explain-the-concept-of-a-channel-adapter) |
| 16 | [What are the different types of Channel Adapters?](#16-what-are-the-different-types-of-channel-adapters) |
| 17 | [Describe the use of a Service Activator.](#17-describe-the-use-of-a-service-activator) |
| 18 | [What is a Gateway in Spring Integration?](#18-what-is-a-gateway-in-spring-integration) |
| 19 | [How do you configure a Gateway?](#19-how-do-you-configure-a-gateway) |
| 20 | [Explain Inbound and Outbound Gateways.](#20-explain-inbound-and-outbound-gateways) |
| 21 | [What is a Message Flow in Spring Integration?](#21-what-is-a-message-flow-in-spring-integration) |
| 22 | [How do you implement Publish-Subscribe channels?](#22-how-do-you-implement-publish-subscribe-channels) |
| 23 | [What is the role of a Message Selector?](#23-what-is-the-role-of-a-message-selector) |
| 24 | [How can you integrate Spring Integration with JMS?](#24-how-can-you-integrate-spring-integration-with-jms) |
| 25 | [Explain the use of SFTP/SCP adapters in Spring Integration.](#25-explain-the-use-of-sftp-scp-adapters-in-spring-integration) |
| 26 | [How do you handle transactions in Spring Integration?](#26-how-do-you-handle-transactions-in-spring-integration) |
| 27 | [What is a Bridge in Spring Integration?](#27-what-is-a-bridge-in-spring-integration) |
| 28 | [Describe the concept of a Messaging Gateway Interface.](#28-describe-the-concept-of-a-messaging-gateway-interface) |
| 29 | [What are the benefits of using Spring Integration over traditional messaging?](#29-what-are-the-benefits-of-using-spring-integration-over-traditional-messaging) |
| 30 | [Explain the use of the `@MessagingGateway` annotation.](#30-explain-the-use-of-the-messaginggateway-annotation) |
| 31 | [What is a Channel Interceptor?](#31-what-is-a-channel-interceptor) |
| 32 | [How do you implement retry logic in Spring Integration?](#32-how-do-you-implement-retry-logic-in-spring-integration) |
| 33 | [What is a Barrier in Spring Integration?](#33-what-is-a-barrier-in-spring-integration) |
| 34 | [How do you use Spring Integration with RabbitMQ?](#34-how-do-you-use-spring-integration-with-rabbitmq) |
| 35 | [Explain the concept of a Wire Tap.](#35-explain-the-concept-of-a-wire-tap) |
| 36 | [What is a Control Bus in Spring Integration?](#36-what-is-a-control-bus-in-spring-integration) |
| 37 | [How do you configure a Scatter-Gather pattern in Spring Integration?](#37-how-do-you-configure-a-scatter-gather-pattern-in-spring-integration) |
| 38 | [Describe the role of a Payload in Spring Integration.](#38-describe-the-role-of-a-payload-in-spring-integration) |
| 39 | [How do you use Spring Integration with Web Services?](#39-how-do-you-use-spring-integration-with-web-services) |
| 40 | [What is the purpose of the IntegrationFlow?](#40-what-is-the-purpose-of-the-integrationflow) |
| 41 | [How do you implement a custom transformer in Spring Integration?](#41-how-do-you-implement-a-custom-transformer-in-spring-integration) |
| 42 | [What is an Executor Channel?](#42-what-is-an-executor-channel) |
| 43 | [How do you implement a custom filter in Spring Integration?](#43-how-do-you-implement-a-custom-filter-in-spring-integration) |
| 44 | [Describe the concept of a Delayer.](#44-describe-the-concept-of-a-delayer) |
| 45 | [How do you monitor Spring Integration applications?](#45-how-do-you-monitor-spring-integration-applications) |
| 46 | [What is the role of Integration Management in Spring Integration?](#46-what-is-the-role-of-integration-management-in-spring-integration) |
| 47 | [How do you handle message headers in Spring Integration?](#47-how-do-you-handle-message-headers-in-spring-integration) |
| 48 | [Explain the concept of a Message History.](#48-explain-the-concept-of-a-message-history) |
| 49 | [How do you use Spring Integration with Kafka?](#49-how-do-you-use-spring-integration-with-kafka) |
| 50 | [What are the best practices for designing Spring Integration flows?](#50-what-are-the-best-practices-for-designing-spring-integration-flows) |
---
# Spring Core Easy Interview Questions and Answers
### 1. What is the Spring Framework?
The Spring Framework is an open-source application framework that provides comprehensive infrastructure support for developing Java applications. It was initially released in 2003 by Rod Johnson. Spring makes it easier to create enterprise-level applications by providing various modules and extensions to build robust and maintainable applications.
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 2. What are the advantages of using Spring Framework?
- **Modularity**: Spring is divided into several modules, allowing developers to use only the parts they need.
- **Dependency Injection**: Promotes loose coupling by allowing objects to be injected into other objects.
- **Aspect-Oriented Programming (AOP)**: Helps separate cross-cutting concerns such as logging, security, and transaction management.
- **Transaction Management**: Simplifies the management of transactions.
- **Integration with Other Frameworks**: Easily integrates with other frameworks like Hibernate, JPA, and Struts.
- **Testability**: Provides support for unit testing and integration testing.
- **Community Support**: Large community and extensive documentation.
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 3. Explain Dependency Injection.
Dependency Injection (DI) is a design pattern that allows an object to be created and injected with its dependencies by an external entity. This promotes loose coupling between objects and enhances testability and maintainability.
**Example:**
```java
// Service interface
public interface MessageService {
void sendMessage(String message, String receiver);
}
// Service implementation
public class EmailService implements MessageService {
@Override
public void sendMessage(String message, String receiver) {
System.out.println("Email sent to " + receiver + " with Message: " + message);
}
}
// Consumer class
public class MyApplication {
private MessageService service;
// Constructor-based dependency injection
public MyApplication(MessageService service) {
this.service = service;
}
public void processMessage(String message, String receiver) {
service.sendMessage(message, receiver);
}
}
// Main class
public class MainApp {
public static void main(String[] args) {
// Injecting dependency
MessageService service = new EmailService();
MyApplication app = new MyApplication(service);
app.processMessage("Hello", "john@example.com");
}
}
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 4. What are the different types of Dependency Injection?
- **Constructor Injection**: Dependencies are provided through a class constructor.
- **Setter Injection**: Dependencies are provided through setter methods.
- **Interface Injection**: Dependencies are provided through an interface method (less common).
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 5. What is the BeanFactory in Spring?
BeanFactory is the root interface for accessing a Spring bean container. It provides the configuration framework and basic functionality for managing beans. BeanFactory is lightweight and is typically used in simple applications or scenarios where resources are limited.
**Example:**
```java
// XML Configuration (beans.xml)
// Java Code
public class MainApp {
public static void main(String[] args) {
Resource resource = new ClassPathResource("beans.xml");
BeanFactory factory = new XmlBeanFactory(resource);
MyBean myBean = (MyBean) factory.getBean("myBean");
myBean.doSomething();
}
}
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 6. What is the ApplicationContext in Spring?
ApplicationContext is an extension of BeanFactory that provides more advanced features. It includes functionalities such as internationalization, event propagation, declarative mechanisms to create a bean, and various ways to look up a bean. It is more feature-rich and is typically used in enterprise applications.
**Example:**
```java
// XML Configuration (beans.xml)
// Java Code
public class MainApp {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
MyBean myBean = (MyBean) context.getBean("myBean");
myBean.doSomething();
}
}
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 7. What is the difference between BeanFactory and ApplicationContext?
| Feature | BeanFactory | ApplicationContext |
|--------------------|------------------------------------------|---------------------------------------------|
| Initialization | Lazy initialization | Eager initialization |
| Advanced Features | Limited | Provides advanced features like event propagation, declarative mechanisms, etc. |
| Internationalization | Not supported | Supported |
| Event Handling | Not supported | Supported |
| Dependency Injection | Basic | Advanced (supports annotations, AOP, etc.) |
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 8. How do you configure a Spring application using XML?
**Example:**
```xml
```
```java
// Java Code
public class MainApp {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
MyBean myBean = (MyBean) context.getBean("myBean");
myBean.doSomething();
}
}
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 9. What is a Spring Bean?
A Spring Bean is an object that is instantiated, assembled, and otherwise managed by the Spring IoC (Inversion of Control) container. Beans are the fundamental building blocks of a Spring application.
**Example:**
```java
public class MyBean {
private String property;
public void setProperty(String property) {
this.property = property;
}
public void doSomething() {
System.out.println("Property value: " + property);
}
}
```
```xml
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 10. What are the different scopes of Spring Beans?
- **Singleton**: Only one instance of the bean is created for the Spring container. This is the default scope.
- **Prototype**: A new instance is created each time the bean is requested.
- **Request**: A new instance is created for each HTTP request. Applicable only in the context of a web-aware Spring ApplicationContext.
- **Session**: A new instance is created for each HTTP session. Applicable only in the context of a web-aware Spring ApplicationContext.
- **Global-session**: A single instance is created for the global HTTP session. Applicable only in the context of a web-aware Spring ApplicationContext.
**Example:**
```xml
```
```java
public class MainApp {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
// Singleton Scope
SingletonBean singletonBean1 = (SingletonBean) context.getBean("singletonBean");
SingletonBean singletonBean2 = (SingletonBean) context.getBean("singletonBean");
System.out.println(singletonBean1 == singletonBean2); // true
// Prototype Scope
PrototypeBean prototypeBean1 = (PrototypeBean) context.getBean("prototypeBean");
PrototypeBean prototypeBean2 = (PrototypeBean) context.getBean("prototypeBean");
System.out.println(prototypeBean1 == prototypeBean2); // false
}
}
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 11. How do you define a Spring Bean in XML configuration?
A Spring Bean can be defined in the XML configuration file using the `` element. The `id` attribute specifies the bean's identifier, and the `class` attribute specifies the fully qualified class name of the bean.
**Example:**
```xml
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 12. What is the default scope of a Spring Bean?
The default scope of a Spring Bean is `singleton`. This means that only one instance of the bean is created for the Spring container.
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 13. How do you inject a bean using constructor injection?
Constructor injection is performed by defining a constructor in the bean class and specifying the dependencies in the XML configuration.
**Example:**
```java
public class MyBean {
private final Dependency dependency;
// Constructor
public MyBean(Dependency dependency) {
this.dependency = dependency;
}
public void doSomething() {
dependency.perform();
}
}
```
```xml
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 14. How do you inject a bean using setter injection?
Setter injection is performed by defining setter methods in the bean class and specifying the dependencies in the XML configuration.
**Example:**
```java
public class MyBean {
private Dependency dependency;
// Setter method
public void setDependency(Dependency dependency) {
this.dependency = dependency;
}
public void doSomething() {
dependency.perform();
}
}
```
```xml
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 15. What is the role of the @Autowired annotation?
The `@Autowired` annotation is used for automatic dependency injection in Spring. It can be applied to constructors, setter methods, and fields. Spring will automatically wire the annotated dependency by type.
**Example:**
```java
@Component
public class MyBean {
@Autowired
private Dependency dependency;
public void doSomething() {
dependency.perform();
}
}
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 16. What is the purpose of the @Component annotation?
The `@Component` annotation indicates that a class is a Spring component. It is a generic stereotype for any Spring-managed component and allows Spring to automatically detect and register the bean.
**Example:**
```java
@Component
public class MyBean {
public void doSomething() {
System.out.println("Doing something...");
}
}
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 17. What are Spring stereotypes?
Spring stereotypes are annotations that indicate the role of a Spring-managed component. These annotations help in better organizing and managing the components within a Spring application. Common stereotypes include `@Component`, `@Service`, `@Repository`, and `@Controller`.
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 18. How do you enable component scanning in Spring?
Component scanning is enabled using the `` element in XML configuration or the `@ComponentScan` annotation in Java configuration.
**Example (XML Configuration):**
```xml
```
**Example (Java Configuration):**
```java
@Configuration
@ComponentScan(basePackages = "com.example")
public class AppConfig {
}
```
#### **[⬆ Back to Top](#level--spring-core-easy)**
---
### 19. What is the difference between @Component, @Service, @Repository, and @Controller?
| Annotation | Description