0% found this document useful (0 votes)
43 views41 pages

SpringBoot MCQ

The document provides an overview of various Spring Boot annotations and their purposes, including @SpringBootApplication for simplifying Java application development, @Controller for handling HTTP requests, and @RestController for creating RESTful services. It also covers annotations related to dependency injection, transaction management, and configuration, as well as features for security, caching, and scheduling. Additionally, it includes a basic level quiz with questions about Spring Boot's functionalities and common practices.

Uploaded by

prayagdev109
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views41 pages

SpringBoot MCQ

The document provides an overview of various Spring Boot annotations and their purposes, including @SpringBootApplication for simplifying Java application development, @Controller for handling HTTP requests, and @RestController for creating RESTful services. It also covers annotations related to dependency injection, transaction management, and configuration, as well as features for security, caching, and scheduling. Additionally, it includes a basic level quiz with questions about Spring Boot's functionalities and common practices.

Uploaded by

prayagdev109
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

1.

**@SpringBootApplication**:

- Simplifies the development and deployment of production-ready Java applications by


providing a comprehensive suite of tools, libraries, and pre-configured settings.

- Opinionated framework promoting best practices and conventions to minimize boilerplate


code and streamline development efforts.

2. **@Controller**:

- Marks a class as a controller in Spring MVC, responsible for handling HTTP requests and
returning views or data to clients.

- Works with @RequestMapping to map request URLs to handler methods within the
controller.

3. **@RestController**:

- Specialized for creating RESTful web services by combining @Controller and


@ResponseBody.

- Simplifies the development of REST APIs by automatically serializing return values to JSON
or XML.

4. **@RequestMapping**:

- Maps HTTP requests to handler methods in a controller class, allowing developers to specify
URL paths and HTTP methods.

- Can be applied at the class or method level to define request mappings.

5. **@Autowired**:

- Enables automatic dependency injection in Spring-managed beans by automatically wiring


beans of matching type.
- Can be applied to fields, setter methods, or constructors to inject dependencies into
Spring-managed beans.

6. **@Service**:

- Marks a class as a service component in the business logic layer, encapsulating business
logic, transaction management, and other non-web-related functionalities.

7. **@Repository**:

- Indicates that a class is a data access component, typically used to interact with databases
or other data sources.

- Enables automatic translation of exceptions into Spring's DataAccessException hierarchy.

8. **@Component**:

- Marks a class as a Spring-managed component, making it eligible for auto-detection and


auto-configuration by Spring's component scanning mechanism.

9. **@Configuration**:

- Provides bean definitions and configuration to the Spring application context, allowing for
Java-based configuration as an alternative to XML configuration.

10. **@Bean**:

- Declares a bean within a @Configuration class, providing a way to define and configure
beans explicitly.
11. **@Profile**:

- Allows conditional bean registration based on active profiles in the application context,
enabling different configurations for different environments.

12. **@Value**:

- Injects values from property files, environment variables, or other sources into
Spring-managed beans, allowing for externalized configuration.

13. **@Qualifier**:

- Resolves ambiguity during autowiring by specifying the name of the bean to be injected.

14. **@Scope**:

- Specifies the scope (lifecycle) of a bean in the Spring application context, controlling how
and when bean instances are created, reused, and destroyed.

15. **@Async**:

- Indicates that a method should be executed asynchronously, typically in a separate thread,


useful for offloading long-running or non-blocking tasks.

16. **@EnableScheduling**:

- Enables support for scheduling tasks within a Spring application, allowing methods
annotated with @Scheduled to be executed according to a specified schedule.

17. **@EnableAspectJAutoProxy**:
- Enables support for AspectJ-based annotation-driven aspect configuration, allowing for the
creation and execution of aspects to encapsulate cross-cutting concerns.

18. **@EnableJms**:

- Enables JMS (Java Message Service) integration in a Spring application, providing


infrastructure for sending and receiving messages asynchronously between distributed systems.

19. **@EnableWebSocketMessageBroker**:

- Enables WebSocket messaging with support for a message broker configuration, providing
support for handling WebSocket messages and managing WebSocket connections in Spring
MVC applications.

20. **@EnableResourceServer**:

- Configures the application as an OAuth2 resource server, securing RESTful APIs by


validating access tokens provided by an authorization server.

21. **@EnableAuthorizationServer**:

- Configures the application as an OAuth2 authorization server, responsible for issuing


access tokens and providing endpoints for token generation and user authentication.

22. **@EnableBatchProcessing**:

- Enables support for batch processing within a Spring application, providing infrastructure for
defining and executing batch jobs.

23. **@EnableWebMvc**:
- Enables Spring MVC configuration in a Spring Boot application, allowing for customizing
and extending Spring MVC features.

24. **@EnableJdbcHttpSession**:

- Configures JDBC-based HTTP session management, storing sessions in a relational


database for scalability and fault-tolerance.

25. **@Conditional**:

- Allows conditional bean registration based on specific conditions, providing flexibility in


controlling the instantiation of beans.

26. **@ConditionalOnClass**:

- Registers a bean only if a specific class is present in the classpath, enabling dynamic bean
registration based on dependencies.

27. **@ConditionalOnProperty**:

- Registers a bean only if a specified property is present in the application's environment,


allowing for conditional bean registration based on configuration properties.

28. **@ConditionalOnMissingBean**:

- Registers a bean only if there is no existing bean of the same type, providing default
implementations or fallbacks when a bean is not explicitly defined.

29. **@ConditionalOnExpression**:

- Registers a bean based on the evaluation of a SpEL (Spring Expression Language)


expression, allowing for more complex conditional bean registration logic.

30. **@PropertySource**:

- Specifies the location of property files to be loaded into the Spring environment, allowing for
externalized configuration.

31. **@ComponentScan**:

- Configures component scanning for Spring-managed beans, enabling automatic detection


and registration of components, services, repositories, and other Spring-managed beans.

32. **@Import**:

- Imports additional configuration classes into the current configuration class, allowing for
modularization and composition of configuration.

33. **@ImportResource**:

- Imports XML-based Spring configuration files into the application context, allowing for
integrating existing XML-based configuration with Java-based configuration.

34. **@EnableAutoConfiguration**:

- Enables Spring Boot's auto-configuration mechanism, configuring the application based on


dependencies and reducing the need for manual configuration.

35. **@EnableDiscoveryClient**:

- Enables service discovery functionality for applications using Spring Cloud, allowing the
application to register itself with a service registry.
36. **@EnableEurekaServer**:

- Configures the application as a Eureka service registry server, enabling service registration,
discovery, and health monitoring for other services.

37. **@EnableFeignClients**:

- Enables Feign client functionality for applications using Spring Cloud, simplifying the
creation of REST clients by allowing developers to define interfaces annotated with
@FeignClient.

38. **@FeignClient**:

- Declares a REST client interface for Feign, specifying the name of the target service and the
URL patterns for the REST endpoints.

39. **@EnableZuulProxy**:

- Enables Zuul proxy functionality for applications using Spring Cloud, providing a gateway
service for routing requests to backend services based on configured routes.

40. **@EnableConfigServer**:

- Configures the application as a Spring Cloud Config server, allowing centralized


management and distribution of configuration properties.

41. **@EnableHystrix**:

- Enables Hystrix circuit breaker functionality for applications using Spring Cloud, providing
fault tolerance and resilience by isolating and handling failures in distributed systems.
42. **@EnableHystrixDashboard**:

Enables the Hystrix Dashboard for monitoring Hystrix metrics, providing a graphical user
interface for visualizing circuit breaker states and metrics.

43. **@EnableCircuitBreaker**:

- Enables circuit breaker functionality for methods, automatically wrapping annotated


methods with a circuit breaker to handle failures and fallback to alternative behavior.

44. **@EnableRetry**:

- Enables automatic retry functionality for methods, allowing for the automatic retrying of
failed operations based on configurable retry policies.

45. **@EnableWebSecurity**:

- Enables Spring Security's web security features for the application, allowing developers to
configure authentication, authorization, and CSRF protection.

46. **@EnableGlobalMethodSecurity**:

- Enables method-level security for Spring Security, allowing developers to apply security
annotations such as @Secured and @PreAuthorize to controller methods.

47. **@EnableJpaRepositories**:
- Enables Spring Data JPA repositories for the application, providing CRUD operations and
query methods for interacting with a relational database using JPA.

48. **@EnableTransactionManagement**:

- Enables Spring's transaction management features for the application, allowing developers
to annotate methods with @Transactional to specify transactional behavior.

49. **@Entity**:

- Marks a Java class as an entity, representing a persistent object in a relational database


and providing metadata for object-relational mapping.

50. **@Table**:

- Specifies the database table associated with an entity class, allowing developers to
customize table properties such as name, schema, and constraints.

51. **@Id**:

- Marks a field as the primary key of an entity, defining the unique identifier for database
records and ensuring object identity within the persistence context.

52. **@GeneratedValue**:

- Specifies the strategy for generating primary key values automatically, allowing developers
to configure how primary key values are assigned to entity instances.

53. **@Column**:
- Specifies the mapping between an entity field and a database column, providing
fine-grained control over the database schema generated by ORM frameworks.

54. **@OneToMany**:

- Defines a one-to-many relationship between entities, allowing developers to specify a


collection of related entities as a field in the owning entity class.

55. **@ManyToOne**:

- Defines a many-to-one relationship between entities, representing the owning side of the
association and typically used to model parent-child relationships.

56. **@JoinTable**:

- Specifies the join table for a many-to-many relationship between entities, allowing
developers to map a many-to-many association by defining an intermediate table.

57. **@Transactional**:

- Marks a method, class, or interface as transactional, indicating that it should be executed


within a transactional context and providing declarative transaction management.

58. **@Cacheable**:

- Marks a method's return value for caching, allowing for the storage of method results in the
cache for improved performance and efficiency.

59. **@CachePut**:

- Updates the value in the cache for a method regardless of the cache's current contents,
useful for updating cached data when the underlying data changes.

60. **@CacheEvict**:

- Removes entries from the cache to maintain consistency between cached data and the
underlying data source, allowing for the invalidation of cached data.

61. **@Valid**:

- Indicates that a method parameter should be validated against constraints defined in its
associated bean validation annotations, providing data integrity and validation.

62. **@Validated**:

- Provides group-based validation for method parameters, allowing developers to specify


validation groups that should be applied during method parameter validation.

63. **@PathVariable**:

- Binds a method parameter to a URI template variable in a Spring MVC controller, allowing
developers to extract variable values from the request URI.

64. **@RequestBody**:

- Binds the body of a HTTP request to a method parameter in a Spring MVC controller,
converting the request body to the specified parameter type.

65. **@ResponseBody**:

- Indicates that a method return value should be serialized directly into the HTTP response
body, useful for returning data directly from controller methods.
66. **@ModelAttribute**:

- Binds a method parameter to a model attribute in a Spring MVC controller, adding the
annotated parameter to the model before rendering a view.

67. **@ExceptionHandler**:

- Defines a method to handle exceptions thrown during request processing in a Spring MVC
controller, allowing for centralized exception handling logic.

68. **@ControllerAdvice**:

- Marks a class as a global controller advice, providing centralized exception handling for all
controllers in the application.

69. **@CrossOrigin**:

- Configures cross-origin resource sharing (CORS) for Spring MVC controllers, allowing for
enabling cross-origin requests from web browsers to backend APIs.

70. **@EnableSwagger2**:

- Enables Swagger support for documenting and testing RESTful APIs in a Spring Boot
application, providing a user-friendly interface for exploring and interacting with API endpoints.

71. **@ApiOperation**:

- Adds metadata to describe an API operation in Swagger documentation, allowing


developers to specify details such as operation summary, description, and parameters.
72. **@ApiParam**:

- Adds metadata to describe parameters of an API operation in Swagger documentation,


allowing developers to specify parameter details such as name, description, data type, and
constraints.

73. **@ApiResponse**:

- Adds metadata to describe possible responses of an API operation in Swagger


documentation, allowing developers to specify details such as response code, description, and
response schema.

74. **@EnableConfigurationProperties**:

- Enables support for binding external configuration properties to Spring beans, allowing for
externalized configuration and injecting properties into Spring components.

75. **@RequestBodyAdvice**:

- Intercepts and customizes HTTP request bodies before they are bound to method
parameters in Spring MVC controllers, allowing for preprocessing or validation of request
bodies.

76. **@ResponseBodyAdvice**:

- Intercepts and customizes HTTP response bodies before they are serialized and sent to
clients in Spring MVC controllers, allowing for preprocessing or modification of response bodies.

77. **@EventListener**:

- Marks a method as an event listener, allowing it to receive and handle application events,
providing a convenient mechanism for implementing event-driven architectures.

78. **@Scheduled**:

- Defines a method to be executed periodically according to a fixed schedule, useful for


implementing background tasks, periodic data updates, or scheduled maintenance activities.

79. **@Retryable**:

- Indicates that a method should be retried automatically if it fails due to a specified exception,
providing resilience and improving the reliability of critical operations.

Basic Level
1. What is Spring Boot primarily used for?
- A. Building Android applications
- B. Creating web applications in Java
- C. Developing desktop applications
- D. Building machine learning models
- **Answer: B. Creating web applications in Java**

2. Which annotation is used to mark the main class in a Spring Boot application?
- A. @MainClass
- B. @SpringBootApplication
- C. @StartClass
- D. @MainApplication
- **Answer: B. @SpringBootApplication**

3. What is the purpose of the @RestController annotation in Spring Boot?


- A. To define a controller class
- B. To enable Spring MVC
- C. To create RESTful web services
- D. To define a service class
- **Answer: C. To create RESTful web services**

4. Which file is commonly used to configure application properties in Spring Boot?


- A. application.properties
- B. config.properties
- C. spring.properties
- D. app.properties
- **Answer: A. application.properties**

5. How does Spring Boot simplify dependency management?


- A. By providing built-in support for Maven
- B. By automatically resolving version conflicts
- C. By providing a graphical interface for dependency management
- D. By using XML configuration files
- **Answer: B. By automatically resolving version conflicts**

6. What is the default embedded web server provided by Spring Boot?


- A. Apache Tomcat
- B. Jetty
- C. WildFly
- D. JBoss
- **Answer: A. Apache Tomcat**

7. Which command is used to run a Spring Boot application?


- A. java -jar
- B. mvn spring-boot:run
- C. gradle bootRun
- D. All of the above
- **Answer: D. All of the above**

8. What is the purpose of Spring Boot Starters?


- A. To configure the Spring Boot application
- B. To include common dependencies for specific functionalities
- C. To manage database connections
- D. To define URL mappings
- **Answer: B. To include common dependencies for specific functionalities**

9. How does Spring Boot simplify the creation of RESTful web services?
- A. By providing annotations like @RestController
- B. By generating code based on configuration
- C. By automatically configuring servlets
- D. By abstracting away HTTP protocols
- **Answer: A. By providing annotations like @RestController**

10. What is the purpose of the @Autowired annotation in Spring Boot?


- A. To create a new instance of a class
- B. To inject dependencies automatically
- C. To define a primary bean
- D. To enable component scanning
- **Answer: B. To inject dependencies automatically**

11. How does Spring Boot support auto-configuration?


- A. By using annotations like @EnableAutoConfiguration
- B. By scanning the classpath for specific libraries
- C. By providing default configurations for common use cases
- D. All of the above
- **Answer: D. All of the above**

12. What is Spring Boot Actuator used for?


- A. To create RESTful web services
- B. To monitor and manage Spring Boot applications
- C. To handle security configurations
- D. To configure embedded web servers
- **Answer: B. To monitor and manage Spring Boot applications**

13. How does Spring Boot simplify dependency management?


- A. By using a centralized dependency management tool
- B. By providing Spring Boot Starters
- C. By automatically resolving version conflicts
- D. All of the above
- **Answer: D. All of the above**

14. What is the purpose of the application.properties (or application.yml) file in Spring Boot?
- A. To define application-specific properties
- B. To configure datasource properties
- C. To set logging levels
- D. All of the above
- **Answer: D. All of the above**

15. How does Spring Boot handle externalized configuration?


- A. By reading properties from environment variables
- B. By scanning configuration files in predefined locations
- C. By using the @Value annotation to inject properties
- D. All of the above
- **Answer: D. All of the above**

16. What is the purpose of the @RestController annotation in Spring Boot?


- A. To define a controller class
- B. To indicate that the class is a RESTful controller
- C. To enable component scanning
- D. All of the above
- **Answer: B. To indicate that the class is a RESTful controller**

17. How does Spring Boot simplify unit testing?


- A. By providing a built-in testing framework
- B. By supporting mock object libraries like Mockito
- C. By automatically configuring test environments
- D. All of the above
- **Answer: D. All of the above**

18. What is the purpose of Spring Boot's CommandLineRunner interface?


- A. To run tasks before the application starts up
- B. To define command-line arguments for the application
- C. To handle HTTP requests and responses
- D. To create RESTful web services
- **Answer: A. To run tasks before the application starts up**

19. How does Spring Boot support internationalization?


- A. By providing message source beans
- B. By using locale-specific configuration properties
- C. By supporting message interpolation
- D. All of the above
- **Answer: D. All of the above**

20. What is the purpose of

Spring Boot's SpringApplication class?


- A. To configure the Spring application context
- B. To start the Spring Boot application
- C. To manage database connections
- D. All of the above
- **Answer: B. To start the Spring Boot application**

21. How does Spring Boot support logging?


- A. By using the SLF4J API
- B. By providing default logging configurations
- C. By supporting logging frameworks like Logback and Log4j
- D. All of the above
- **Answer: D. All of the above**

22. What is the purpose of Spring Boot's CommandLinePropertySource?


- A. To load properties from command-line arguments
- B. To define properties for command-line applications
- C. To manage environment-specific properties
- D. All of the above
- **Answer: A. To load properties from command-line arguments**

23. How does Spring Boot handle profile-specific configuration?


- A. By using profile-specific configuration files
- B. By using the @Profile annotation
- C. By providing profile-specific property sources
- D. All of the above
- **Answer: D. All of the above**

24. What is the purpose of Spring Boot's @Conditional annotation?


- A. To conditionally enable components based on certain conditions
- B. To define conditional statements in configuration files
- C. To configure conditional beans
- D. All of the above
- **Answer: A. To conditionally enable components based on certain conditions**

25. How does Spring Boot handle externalized configuration?


- A. By providing properties files outside the application JAR
- B. By using environment variables
- C. By reading properties from the classpath
- D. All of the above
- **Answer: D. All of the above**

26. What is the purpose of the Spring Boot Starter Parent?


- A. To define the parent project in a Maven multi-module project
- B. To provide common configuration for Spring Boot projects
- C. To manage dependencies in a Spring Boot project
- D. All of the above
- **Answer: B. To provide common configuration for Spring Boot projects**

27. How does Spring Boot handle property binding?


- A. By using reflection
- B. By providing a type-safe way to bind properties
- C. By using XML configuration files
- D. All of the above
- **Answer: B. By providing a type-safe way to bind properties**

28. What is the purpose of Spring Boot's @ConfigurationProperties annotation?


- A. To define properties files for configuration
- B. To bind properties to Java objects
- C. To enable component scanning
- D. All of the above
- **Answer: B. To bind properties to Java objects**

29. How does Spring Boot simplify the creation of command-line applications?
- A. By providing annotations like @CommandLineApp
- B. By generating code based on configuration
- C. By providing a SpringApplication class
- D. All of the above
- **Answer: C. By providing a SpringApplication class**

30. What is the purpose of Spring Boot's @SpringBootTest annotation?


- A. To enable component scanning
- B. To define properties for test environments
- C. To create an ApplicationContext for testing
- D. All of the above
- **Answer: C. To create an ApplicationContext for testing**

31. How does Spring Boot simplify the creation of database connections?
- A. By providing built-in support for JDBC
- B. By automatically configuring datasource beans
- C. By generating SQL queries from entity classes
- D. All of the above
- **Answer: D. All of the above**

32. What is the purpose of Spring Boot's @EnableAutoConfiguration annotation?


- A. To enable auto-configuration of Spring beans
- B. To enable auto-configuration of web security
- C. To enable auto-configuration of logging
- D. All of the above
- **Answer: A. To enable auto-configuration of Spring beans**

33. How does Spring Boot handle static resources?


- A. By serving them from the classpath
- B. By serving them from the web root directory
- C. By generating them dynamically
- D. All of the above
- **Answer: D. All of the above**

34. What is the purpose of Spring Boot's @ConditionalOnProperty annotation?


- A. To conditionally enable beans based on certain properties
- B. To conditionally enable beans based on certain profiles
- C. To conditionally enable beans based on environment variables
- D. All of the above
- **Answer: A. To conditionally enable beans based on certain properties**
35. How does Spring Boot simplify testing of RESTful web services?
- A. By providing a built-in REST client
- B. By supporting mock objects
- C. By providing annotations like @WebMvcTest
- D. All of the above
- **Answer: D. All of the above**

36. What is the purpose of Spring Boot's @EnableWebMvc annotation?


- A. To enable Spring MVC
- B. To enable Spring WebFlux
- C. To enable Spring Security
- D. All of the above
- **Answer: A. To enable Spring MVC**

37. How does Spring Boot simplify exception handling?


- A. By providing default error pages
- B. By supporting global exception handlers
- C. By providing annotations like @ControllerAdvice
- D. All of the above
- **Answer: D. All of the above**

38. What is the purpose of Spring Boot's @EnableTransactionManagement annotation?


- A. To enable transaction management
- B. To enable caching
- C. To enable scheduling
- D. All of the above
- **Answer: A. To enable transaction management**

39. How does Spring Boot simplify the creation of scheduled tasks?
- A. By providing annotations like @Scheduled
- B. By generating code based on configuration
- C. By automatically configuring task schedulers
- D. All of the above
- **Answer: A. By providing annotations like @Scheduled**

40. What is the purpose of Spring Boot's @EnableCaching annotation?


- A. To enable caching
- B. To enable transaction management
- C. To enable scheduling
- D. All of the above
- **Answer: A. To enable caching**

Intermediate Level

1. What is the purpose of Spring Boot's @ComponentScan annotation?


- A. To enable component scanning for Spring beans
- B. To specify the base package for Spring Boot application
- C. To enable auto-configuration of Spring beans
- D. To enable Spring Security
- **Answer: A. To enable component scanning for Spring beans**

2. How does Spring Boot simplify database transactions?


- A. By providing annotations like @Transactional
- B. By automatically configuring database connections
- C. By generating SQL queries from entity classes
- D. By providing built-in support for JPA
- **Answer: A. By providing annotations like @Transactional**

3. What is the purpose of Spring Boot's @RequestMapping annotation?


- A. To specify the base URL for RESTful endpoints
- B. To define request mapping for controller methods
- C. To enable global exception handling
- D. To define URL patterns for static resources
- **Answer: B. To define request mapping for controller methods**

4. How does Spring Boot simplify security configuration?


- A. By providing built-in support for OAuth
- B. By generating security configurations based on user roles
- C. By providing annotations like @EnableWebSecurity
- D. By automatically configuring security settings
- **Answer: C. By providing annotations like @EnableWebSecurity**

5. What is the purpose of Spring Boot's @EnableJpaRepositories annotation?


- A. To enable JPA entity scanning
- B. To enable JPA repository scanning
- C. To configure JPA entity managers
- D. To define custom JPA query methods
- **Answer: B. To enable JPA repository scanning**

6. How does Spring Boot simplify error handling in RESTful APIs?


- A. By providing default error pages
- B. By supporting global exception handlers
- C. By providing annotations like @RestControllerAdvice
- D. By generating error responses automatically
- **Answer: C. By providing annotations like @RestControllerAdvice**

7. What is the purpose of Spring Boot's @Entity annotation?


- A. To specify the base URL for RESTful endpoints
- B. To mark a class as a JPA entity
- C. To define request mapping for controller methods
- D. To enable Spring Data JPA repositories
- **Answer: B. To mark a class as a JPA entity**

8. How does Spring Boot simplify integration testing?


- A. By providing built-in support for JUnit
- B. By automatically configuring test environments
- C. By using embedded databases for testing
- D. All of the above
- **Answer: D. All of the above**

9. What is the purpose of Spring Boot's @PathVariable annotation?


- A. To define path variables in RESTful endpoints
- B. To specify the base URL for RESTful endpoints
- C. To define request mapping for controller methods
- D. To enable global exception handling
- **Answer: A. To define path variables in RESTful endpoints**

10. How does Spring Boot simplify the creation of RESTful clients?
- A. By providing annotations like @RestClient
- B. By using the RestTemplate class
- C. By automatically generating client code
- D. By providing built-in support for Apache HttpClient
- **Answer: B. By using the RestTemplate class**

11. What is the purpose of Spring Boot's @Validated annotation?


- A. To validate form inputs in web applications
- B. To enable bean validation for method arguments
- C. To enable transaction validation
- D. To enable global exception handling
- **Answer: B. To enable bean validation for method arguments**

12. How does Spring Boot handle application properties in YAML format?
- A. By providing a dedicated YAML configuration class
- B. By using the @YamlPropertySource annotation
- C. By reading properties from application.yml files
- D. All of the above
- **Answer: C. By reading properties from application.yml files**

13. What is the purpose of Spring Boot's @Scheduled annotation?


- A. To define scheduled tasks in Spring Boot applications
- B. To schedule database backups
- C. To enable scheduling of RESTful endpoints
- D. To specify the scheduling interval for database transactions
- **Answer: A. To define scheduled tasks in Spring Boot applications**

14. How does Spring Boot simplify asynchronous processing?


- A. By providing built-in support for multithreading
- B. By using the @Async annotation
- C. By automatically configuring message queues
- D. All of the above
- **Answer: B. By using the @Async annotation**

15. What is the purpose of Spring Boot's @Profile annotation?


- A. To define application profiles for different environments
- B. To specify the base URL for RESTful endpoints
- C. To enable component scanning for specific profiles
- D. To enable global exception handling
- **Answer: A. To define application profiles for different environments**

16. How does Spring Boot simplify the creation of CRUD operations?
- A. By providing default implementations for repository interfaces
- B. By generating SQL queries from entity classes
- C. By using the @CrudRepository annotation
- D. All of the above
- **Answer: D. All of the above**

17. What is the purpose of Spring Boot's @CrossOrigin annotation?


- A. To specify the origin of incoming HTTP requests
- B. To enable cross-origin resource sharing (CORS)

- C. To configure database connections


- D. To define URL patterns for static resources
- **Answer: B. To enable cross-origin resource sharing (CORS)**

18. How does Spring Boot support logging with Logback?


- A. By providing a Logback configuration file
- B. By using the @EnableLogging annotation
- C. By automatically configuring Logback
- D. By using the SLF4J API
- **Answer: A. By providing a Logback configuration file**

19. What is the purpose of Spring Boot's @Bean annotation?


- A. To define a bean in the Spring application context
- B. To enable auto-configuration of Spring beans
- C. To configure datasource properties
- D. To enable component scanning
- **Answer: A. To define a bean in the Spring application context**

20. How does Spring Boot simplify testing of JPA repositories?


- A. By providing built-in support for JUnit
- B. By using embedded databases for testing
- C. By providing annotations like @DataJpaTest
- D. All of the above
- **Answer: C. By providing annotations like @DataJpaTest**

21. What is the purpose of Spring Boot's @MockBean annotation?


- A. To create mock instances of Spring beans
- B. To enable mocking of RESTful endpoints
- C. To define mock database connections
- D. To enable global exception handling
- **Answer: A. To create mock instances of Spring beans**

22. How does Spring Boot support customization of error pages?


- A. By providing built-in error page templates
- B. By using the @ControllerAdvice annotation
- C. By configuring error page mappings in application.properties
- D. All of the above
- **Answer: C. By configuring error page mappings in application.properties**

23. What is the purpose of Spring Boot's @EnableTransactionManagement annotation?


- A. To enable transaction management
- B. To enable caching
- C. To enable scheduling
- D. All of the above
- **Answer: A. To enable transaction management**

24. How does Spring Boot simplify the creation of scheduled tasks?
- A. By providing annotations like @Scheduled
- B. By generating code based on configuration
- C. By automatically configuring task schedulers
- D. All of the above
- **Answer: A. By providing annotations like @Scheduled**

25. What is the purpose of Spring Boot's @EnableCaching annotation?


- A. To enable caching
- B. To enable transaction management
- C. To enable scheduling
- D. All of the above
- **Answer: A. To enable caching**

26. How does Spring Boot simplify integration testing with external services?
- A. By providing built-in support for WireMock
- B. By automatically configuring test environments
- C. By using embedded databases for testing
- D. All of the above
- **Answer: A. By providing built-in support for WireMock**

27. What is the purpose of Spring Boot's @TestPropertySource annotation?


- A. To define properties for test environments
- B. To enable component scanning for test classes
- C. To specify the base URL for RESTful endpoints in tests
- D. To enable global exception handling for tests
- **Answer: A. To define properties for test environments**

28. How does Spring Boot support conditional bean creation?


- A. By using the @ConditionalOnProperty annotation
- B. By providing annotations like @Conditional
- C. By using profile-specific configuration files
- D. All of the above
- **Answer: D. All of the above**

29. What is the purpose of Spring Boot's @Value annotation?


- A. To inject properties into Spring beans
- B. To define URL patterns for static resources
- C. To enable global exception handling
- D. To define application profiles for different environments
- **Answer: A. To inject properties into Spring beans**

30. How does Spring Boot handle internationalization?


- A. By providing built-in support for resource bundles
- B. By using locale-specific configuration properties
- C. By supporting message interpolation
- D. All of the above
- **Answer: D. All of the above**
31. What is the purpose of Spring Boot's @Async annotation?
- A. To enable asynchronous processing of method calls
- B. To define asynchronous RESTful endpoints
- C. To schedule asynchronous tasks
- D. To enable asynchronous database transactions
- **Answer: A. To enable asynchronous processing of method calls**

32. How does Spring Boot simplify testing of RESTful endpoints?


- A. By providing built-in support for REST Assured
- B. By automatically configuring test environments
- C. By using embedded databases for testing
- D. All of the above
- **Answer: A. By providing built-in support for REST Assured**

33. What is the purpose of Spring Boot's @EntityScan annotation?


- A. To specify the base package for JPA entities
- B. To enable JPA entity scanning
- C. To enable component scanning for entity classes
- D. To define URL patterns for static resources
- **Answer: A. To specify the base package for JPA entities**

34. How does Spring Boot simplify the configuration of embedded databases?
- A. By providing built-in support for H2 Database
- B. By using embedded-database.properties files
- C. By automatically configuring datasource beans
- D. All of the above
- **Answer: C. By automatically configuring datasource beans**

35. What is

the purpose of Spring Boot's @JdbcTemplate annotation?


- A. To define JDBC templates for database access
- B. To enable auto-configuration of Spring beans
- C. To configure datasource properties
- D. To enable component scanning
- **Answer: A. To define JDBC templates for database access**

36. How does Spring Boot simplify integration testing with external services?
- A. By providing built-in support for WireMock
- B. By automatically configuring test environments
- C. By using embedded databases for testing
- D. All of the above
- **Answer: A. By providing built-in support for WireMock**

37. What is the purpose of Spring Boot's @WebMvcTest annotation?


- A. To enable integration testing of Spring MVC controllers
- B. To define request mapping for controller methods
- C. To enable component scanning for web applications
- D. To specify the base URL for RESTful endpoints
- **Answer: A. To enable integration testing of Spring MVC controllers**

38. How does Spring Boot handle static resources?


- A. By serving them from the classpath
- B. By serving them from the web root directory
- C. By generating them dynamically
- D. All of the above
- **Answer: D. All of the above**

39. What is the purpose of Spring Boot's @Value annotation?


- A. To inject properties into Spring beans
- B. To define URL patterns for static resources
- C. To enable global exception handling
- D. To define application profiles for different environments
- **Answer: A. To inject properties into Spring beans**

40. How does Spring Boot handle internationalization?


- A. By providing built-in support for resource bundles
- B. By using locale-specific configuration properties
- C. By supporting message interpolation
- D. All of the above
- **Answer: D. All of the above**


Advanced Level

1. Which annotation is used to enable Spring Data JPA repositories in a Spring Boot
application?
- A. @EnableJpaRepositories
- B. @EnableTransactionManagement
- C. @EnableAutoConfiguration
- D. @EnableWebMvc
- **Answer: A. @EnableJpaRepositories**

2. How does Spring Boot manage transactions by default?


- A. Using JTA (Java Transaction API)
- B. Using programmatic transaction management
- C. Using declarative transaction management
- D. Transactions are not managed by default
- **Answer: C. Using declarative transaction management**

3. What is the purpose of Spring Boot's Actuator module?


- A. To enable cross-origin resource sharing (CORS)
- B. To monitor and manage Spring Boot applications
- C. To provide authentication and authorization mechanisms
- D. To automate deployment processes
- **Answer: B. To monitor and manage Spring Boot applications**

4. Which dependency is commonly used for integrating Spring Boot applications with Apache
Kafka?
- A. spring-kafka
- B. spring-cloud-starter-stream-kafka
- C. spring-boot-starter-web
- D. spring-boot-starter-actuator
- **Answer: A. spring-kafka**

5. How can you enable HTTPS in a Spring Boot application?


- A. By configuring HTTPS properties in application.properties
- B. By providing a keystore file and configuring server.ssl properties
- C. By using a third-party library for SSL/TLS support
- D. HTTPS is enabled by default in Spring Boot
- **Answer: B. By providing a keystore file and configuring server.ssl properties**

6. Which annotation is used to define custom metrics in Spring Boot Actuator?


- A. @EnableMetrics
- B. @Metered
- C. @Counted
- D. @Timed
- **Answer: D. @Timed**

7. What is the purpose of Spring Boot's @Retryable annotation?


- A. To enable retry logic for failed method invocations
- B. To define retry policies in database transactions
- C. To configure retry intervals in scheduled tasks
- D. To retry failed HTTP requests automatically
- **Answer: A. To enable retry logic for failed method invocations**

8. Which annotation is used to configure circuit breakers in Spring Boot applications?


- A. @EnableCircuitBreaker
- B. @EnableHystrix
- C. @EnableResilience4j
- D. @EnableRetry
- **Answer: A. @EnableCircuitBreaker**

9. How can you customize the error response format in a Spring Boot RESTful API?
- A. By providing a custom exception handler with @ControllerAdvice
- B. By configuring error properties in application.yml
- C. By using the @ErrorFormat annotation
- D. By extending the ResponseEntity class
- **Answer: A. By providing a custom exception handler with @ControllerAdvice**

10. Which annotation is used to enable distributed tracing in Spring Boot applications?
- A. @EnableDistributedTracing
- B. @EnableZipkinTracing
- C. @EnableSleuth
- D. @EnableTrace
- **Answer: C. @EnableSleuth**

11. How does Spring Boot support reactive programming?


- A. By providing built-in support for Reactor
- B. By using annotations like @Reactive
- C. By integrating with RxJava
- D. Spring Boot does not support reactive programming
- **Answer: A. By providing built-in support for Reactor**

12. Which annotation is used to enable Spring Security in a Spring Boot application?
- A. @EnableWebSecurity
- B. @EnableSecurity
- C. @EnableAuthentication
- D. @EnableSecure
- **Answer: A. @EnableWebSecurity**

13. What is the purpose of Spring Boot's @ConditionalOnClass annotation?


- A. To conditionally enable beans based on the presence of a class
- B. To conditionally enable beans based on the absence of a class
- C. To conditionally enable beans based on the value of a property
- D. To conditionally enable beans based on the application context
- **Answer: A. To conditionally enable beans based on the presence of a class**

14. How can you configure a custom banner for a Spring Boot application?
- A. By providing a banner.txt file in the resources directory
- B. By
configuring banner properties in application.yml
- C. By using the @Banner annotation
- D. By extending the Banner interface
- **Answer: A. By providing a banner.txt file in the resources directory**

15. Which annotation is used to enable Spring Boot's reactive WebClient?


- A. @EnableWebFlux
- B. @EnableReactiveClient
- C. @EnableWebClient
- D. @EnableWebFluxClient
- **Answer: A. @EnableWebFlux**

16. How can you configure an embedded Tomcat server to use a custom SSL certificate in a
Spring Boot application?
- A. By configuring server.ssl properties in application.properties
- B. By providing a keystore file and configuring server.ssl properties
- C. By using the @EnableSsl annotation
- D. By extending the TomcatEmbeddedServletContainerFactory class
- **Answer: B. By providing a keystore file and configuring server.ssl properties**

17. What is the purpose of Spring Boot's @Lazy annotation?


- A. To specify lazy initialization for Spring beans
- B. To enable lazy loading of JPA entities
- C. To configure lazy fetching in Hibernate
- D. To enable lazy evaluation of SpEL expressions
- **Answer: A. To specify lazy initialization for Spring beans**

18. Which dependency is commonly used for integrating Spring Boot applications with
Elasticsearch?
- A. spring-boot-starter-elasticsearch
- B. spring-boot-starter-data-elasticsearch
- C. spring-elasticsearch
- D. elasticsearch-spring-boot-starter
- **Answer: B. spring-boot-starter-data-elasticsearch**

19. How can you configure logging levels for different packages in a Spring Boot application?
- A. By using the @LogLevel annotation
- B. By providing logging properties in application.properties
- C. By using the @Logger annotation
- D. By extending the Logger class
- **Answer: B. By providing logging properties in application.properties**
20. Which annotation is used to enable caching in a Spring Boot application?
- A. @EnableCaching
- B. @EnableCache
- C. @EnableCacheManagement
- D. @EnableSpringCache
- **Answer: A. @EnableCaching**

21. How does Spring Boot simplify the configuration of WebSocket endpoints?
- A. By using the @WebSocketEndpoint annotation
- B. By providing built-in support for STOMP over WebSocket
- C. By configuring WebSocket properties in application.properties
- D. By extending the WebSocketConfigurer interface
- **Answer: B. By providing built-in support for STOMP over WebSocket**

22. What is the purpose of Spring Boot's @Async annotation?


- A. To enable asynchronous processing of method calls
- B. To define asynchronous RESTful endpoints
- C. To schedule asynchronous tasks
- D. To enable asynchronous database transactions
- **Answer: A. To enable asynchronous processing of method calls**

23. Which annotation is used to enable server-sent events (SSE) in a Spring Boot application?
- A. @EnableSse
- B. @EnableSseSupport
- C. @EnableServerSentEvents
- D. @EnableEventSource
- **Answer: B. @EnableSseSupport**

24. How can you configure Spring Boot to use a custom Jackson ObjectMapper?
- A. By providing custom ObjectMapper properties in application.properties
- B. By using the @JsonMapper annotation
- C. By configuring ObjectMapper beans in a @Configuration class
- D. By extending the JacksonObjectMapper class
- **Answer: C. By configuring ObjectMapper beans in a @Configuration class**

25. What is the purpose of Spring Boot's @RestControllerAdvice annotation?


- A. To define global exception handlers for REST controllers
- B. To provide advice to RESTful endpoints
- C. To enable RESTful services in Spring Boot
- D. To configure RESTful security
- **Answer: A. To define global exception handlers for REST controllers**

26. How does Spring Boot support message-driven architectures?


- A. By providing built-in support for Apache Kafka
- B. By using annotations like @MessageListener
- C. By integrating with messaging systems like RabbitMQ
- D. All of the above
- **Answer: D. All of the above**

27. What is the purpose of Spring Boot's @ConditionalOnMissingBean annotation?


- A. To conditionally enable beans if another bean is missing
- B. To conditionally enable beans based on the presence of a bean
- C. To conditionally enable beans based on the value of a property
- D. To conditionally enable beans based on the application context
- **Answer: A. To conditionally enable beans if another bean is missing**

28. How can you configure Spring Boot to use a custom authentication provider?
- A. By providing authentication properties in application.properties
- B. By using the @AuthenticationProvider annotation
- C. By extending the AuthenticationProvider interface
- D. By configuring authentication beans in a @Configuration class
- **Answer: D. By configuring authentication beans in a @Configuration class**

29. Which annotation is used to enable HTTP/2 support in a Spring Boot application?
- A. @EnableHttp2
- B. @EnableHttp2Support
- C. @EnableHttp2Protocol
- D. @EnableHttp2Server
- **Answer: B. @EnableHttp2Support**

30. What is the purpose of Spring Boot's @IntegrationTest annotation?


- A. To enable integration testing of Spring Boot applications
- B. To define integration tests for RESTful endpoints
- C. To configure integration testing environments
- D. @IntegrationTest annotation does not exist in Spring Boot
- **Answer: D. @IntegrationTest annotation does not exist in Spring Boot**

31. How can you enable HTTP compression in a Spring Boot application?
- A. By configuring server.compression properties in application.properties
- B. By using the @EnableHttpCompression annotation
- C. By providing compression properties in application.yml
- D. HTTP compression is enabled by default in Spring Boot
- **Answer: A. By configuring server.compression properties in application.properties**

32. What is the purpose of Spring Boot's @ConditionalOnExpression annotation?


- A. To conditionally enable beans based on Spring Expression Language (SpEL) expressions
- B. To conditionally enable beans based on the value of a property
- C. To conditionally enable beans based on the presence of a class
- D. To conditionally enable beans based on the application context
- **Answer: A. To conditionally enable beans based on Spring Expression Language (SpEL)
expressions**

33. How does Spring Boot support OAuth 2.0 authentication?


- A. By providing built-in support for OAuth 2.0 authorization server
- B. By using annotations like @EnableOAuth2Client
- C. By integrating

with OAuth 2.0 providers like Okta and Keycloak


- D. All of the above
- **Answer: D. All of the above**

34. Which annotation is used to enable Spring Boot's TestRestTemplate?


- A. @EnableTestRestTemplate
- B. @EnableRestTemplateTest
- C. @RestTemplateTest
- D. @TestRestTemplate
- **Answer: D. @TestRestTemplate**

35. How can you customize the JSON serialization format for specific properties in a Spring
Boot application?
- A. By using custom serializers with Jackson ObjectMapper
- B. By providing serialization properties in application.properties
- C. By using annotations like @JsonFormat
- D. By extending the JsonProperty class
- **Answer: A. By using custom serializers with Jackson ObjectMapper**

36. What is the purpose of Spring Boot's @ConditionalOnMissingClass annotation?


- A. To conditionally enable beans if a class is missing from the classpath
- B. To conditionally enable beans based on the presence of a class
- C. To conditionally enable beans based on the value of a property
- D. To conditionally enable beans based on the application context
- **Answer: A. To conditionally enable beans if a class is missing from the classpath**

37. How can you configure Spring Boot to use a custom authentication filter?
- A. By using the @CustomAuthenticationFilter annotation
- B. By extending the AbstractAuthenticationProcessingFilter class
- C. By providing authentication filter properties in application.yml
- D. By configuring authentication filters in a @Configuration class
- **Answer: B. By extending the AbstractAuthenticationProcessingFilter class**
38. Which annotation is used to enable metrics collection in a Spring Boot application?
- A. @EnableMetrics
- B. @EnableActuator
- C. @EnableMetricsCollection
- D. @EnableMicrometerMetrics
- **Answer: D. @EnableMicrometerMetrics**

39. What is the purpose of Spring Boot's @EnableScheduling annotation?


- A. To enable scheduling of tasks in a Spring Boot application
- B. To enable asynchronous processing of method calls
- C. To enable scheduling of RESTful endpoints
- D. To enable scheduling of database transactions
- **Answer: A. To enable scheduling of tasks in a Spring Boot application**

40. How can you enable HTTP/2 support in a Spring Boot application?
- A. By configuring server.http2.enabled property in application.properties
- B. By using the @EnableHttp2 annotation
- C. By providing HTTP/2 properties in application.yml
- D. HTTP/2 support is enabled by default in Spring Boot
- **Answer: A. By configuring server.http2.enabled property in application.properties**

Syntax Based Questions



1. What is the correct syntax for defining a Spring Boot application class?
- A. `@SpringBootApplication class MyApp { }`
- B. `class MyApp { }`
- C. `@SpringBootApp class MyApp { }`
- D. `@EnableSpringBoot class MyApp { }`
- **Answer: A. `@SpringBootApplication class MyApp { }`**

2. Which of the following annotations is incorrectly formatted?


- A. `@Component`
- B. `@Autowired`
- C. `@Service`
- D. `@Bean`
- **Answer: D. `@Bean`**

3. What is the correct syntax for injecting a bean using constructor-based dependency injection
in Spring Boot?
- A. `@Autowired public MyClass(MyDependency dependency) { this.dependency =
dependency; }`
- B. `@Inject public MyClass(MyDependency dependency) { this.dependency = dependency; }`
- C. `@Autowired public void setDependency(MyDependency dependency) { this.dependency
= dependency; }`
- D. `@Inject public void setDependency(MyDependency dependency) { this.dependency =
dependency; }`
- **Answer: A. `@Autowired public MyClass(MyDependency dependency) { this.dependency =
dependency; }`**

4. Which of the following annotations is used to specify the base package for component
scanning in a Spring Boot application incorrectly?
- A. `@ComponentScan(basePackages = "com.example")`
- B. `@ComponentScan(basePackages = {"com.example"})`
- C. `@ComponentScan("com.example")`
- D. `@ComponentScan(basePackageClasses = {MyComponent.class})`
- **Answer: C. `@ComponentScan("com.example")`**

5. What is the correct syntax for defining a JPA repository interface in Spring Boot?
- A. `public interface UserRepository extends JpaRepository<User, Long> { }`
- B. `public class UserRepository extends JpaRepository<User, Long> { }`
- C. `@Repository public interface UserRepository extends JpaRepository<User, Long> { }`
- D. `@Service public interface UserRepository extends JpaRepository<User, Long> { }`
- **Answer: A. `public interface UserRepository extends JpaRepository<User, Long> { }`**

6. Which annotation is used to specify the primary bean among multiple candidates of the same
type?
- A. `@Primary`
- B. `@Main`
- C. `@First`
- D. `@Priority`
- **Answer: A. `@Primary`**

7. What is the correct syntax for defining a request mapping for a RESTful endpoint in Spring
Boot?
- A. `@RequestMapping("/endpoint")`
- B. `@Mapping("/endpoint")`
- C. `@Get("/endpoint")`
- D. `@PostMapping("/endpoint")`
- **Answer: A. `@RequestMapping("/endpoint")`**

8. Which of the following annotations is incorrectly formatted for specifying a property value in
Spring Boot?
- A. `@Value("${my.property}")`
- B. `@PropertySource("classpath:application.properties")`
- C. `@ConfigurationProperties(prefix = "my")`
- D. `@Property("${my.property}")`
- **Answer: D. `@Property("${my.property}")`**

9. What is the correct syntax for defining a transactional method in a Spring Boot service class?
- A. `@Transactional public void myMethod() { }`
- B. `public void myMethod() { @Transactional }`
- C. `@Transaction public void myMethod() { }`
- D. `@Transaction public void myMethod() { @Transactional }`
- **Answer: A. `@Transactional public void myMethod() { }`**

10. Which of the following annotations is used to enable caching in a Spring Boot application?
- A. `@EnableCache`
- B. `@EnableCaching`
- C. `@EnableCached`
- D. `@EnableCaches`
- **Answer: B. `@EnableCaching`**

11. What is the correct syntax for defining a Scheduled task method in Spring Boot?
- A. `@Scheduled public void myTask() { }`
- B. `@Schedule public void myTask() { }`
- C. `@ScheduleTask public void myTask() { }`
- D. `@ScheduledTask public void myTask() { }`
- **Answer: A. `@Scheduled public void myTask() { }`**

12. Which annotation is used to enable Spring Boot's TestRestTemplate for integration testing?
- A. `@EnableTestRestTemplate`
- B. `@EnableRestTemplateTest`
- C. `@RestTemplateTest`
- D. `@TestRestTemplate`
- **Answer: D. `@TestRestTemplate`**

13. What is the correct syntax for configuring an embedded Tomcat server's port in
application.properties?
- A. `server.port=8080`
- B. `spring.port=8080`
- C. `embedded.server.port=8080`
- D. `tomcat.server.port=8080`
- **Answer: A. `server.port=8080`**

14. Which annotation is used to define the entry point of a Spring Boot application for testing
purposes?
- A. `@TestEntryPoint`
- B. `@SpringBootTest`
- C. `@BootApplicationTest`
- D. `@EntryPointTest`
- **Answer: B. `@SpringBootTest`**

15. What is the correct syntax for defining a custom banner for a Spring Boot application in
application.properties?
- A. `spring.banner.location=banner.txt`
- B. `spring.boot.banner=banner.txt`
- C. `spring.banner.text=banner.txt`
- D. `spring.application.banner=banner.txt`
- **Answer: A. `spring.banner.location=banner.txt`**

16. Which of the following annotations is used to enable Spring Boot's Actuator module for
monitoring and managing the application?
- A. `@EnableMonitoring`
- B. `@EnableManagement`
- C. `@EnableActuator`
- D. `@EnableMetrics`
- **Answer: C. `@EnableActuator`**

17. What is the correct syntax for specifying a property value placeholder in Spring Boot's
application.properties file?
- A. `my.property=value`
- B. `${my.property=value}`
- C. `${

my.property=value}`
- D. `{my.property=value}`
- **Answer: A. `my.property=value`**

18. Which annotation is used to define a custom error handler for a specific exception type in
Spring Boot?
- A. `@ExceptionHandler`
- B. `@ErrorHandling`
- C. `@HandleError`
- D. `@Error`
- **Answer: A. `@ExceptionHandler`**

19. What is the correct syntax for defining a custom property in Spring Boot's
application.properties file?
- A. `custom.property=value`
- B. `property.custom=value`
- C. `property.custom: value`
- D. `custom:property=value`
- **Answer: A. `custom.property=value`**

20. Which annotation is used to enable asynchronous processing of method calls in Spring
Boot?
- A. `@EnableAsync`
- B. `@Async`
- C. `@EnableAsynchronous`
- D. `@Asynchronous`
- **Answer: A. `@EnableAsync`**

21. What is the correct syntax for defining a custom configuration class in Spring Boot?
- A. `@Configuration public class MyConfig { }`
- B. `@Config public class MyConfig { }`
- C. `@EnableConfiguration public class MyConfig { }`
- D. `@Configurable public class MyConfig { }`
- **Answer: A. `@Configuration public class MyConfig { }`**

22. Which annotation is used to configure logging levels for different packages in a Spring Boot
application?
- A. `@LogLevel`
- B. `@LogConfig`
- C. `@Logging`
- D. `@Slf4j`
- **Answer: A. `@LogLevel`**

23. What is the correct syntax for defining a custom profile in Spring Boot's
application.properties file?
- A. `spring.profiles.active=my-profile`
- B. `profiles.active=my-profile`
- C. `active.profile=my-profile`
- D. `profile=my-profile`
- **Answer: A. `spring.profiles.active=my-profile`**

24. Which annotation is used to specify the base package for component scanning in a Spring
Boot application?
- A. `@ComponentScan`
- B. `@ScanComponents`
- C. `@BasePackage`
- D. `@ComponentBase`
- **Answer: A. `@ComponentScan`**
25. What is the correct syntax for defining a custom property source in Spring Boot?
- A. `@PropertySource("classpath:custom.properties")`
- B. `@PropertySource("custom.properties")`
- C. `@Property("classpath:custom.properties")`
- D. `@Property("custom.properties")`
- **Answer: A. `@PropertySource("classpath:custom.properties")`**

26. Which annotation is used to enable server-sent events (SSE) support in a Spring Boot
application?
- A. `@EnableSse`
- B. `@EnableSseSupport`
- C. `@EnableServerSentEvents`
- D. `@EnableEventSource`
- **Answer: B. `@EnableSseSupport`**

27. What is the correct syntax for defining a custom message converter in Spring Boot's
configuration class?
- A. `@Bean public MyMessageConverter messageConverter() { }`
- B. `@MessageConverter public MyMessageConverter messageConverter() { }`
- C. `@Converter public MyMessageConverter messageConverter() { }`
- D. `@CustomConverter public MyMessageConverter messageConverter() { }`
- **Answer: A. `@Bean public MyMessageConverter messageConverter() { }`**

28. Which annotation is used to enable HTTP compression in a Spring Boot application?
- A. `@EnableCompression`
- B. `@EnableHttpCompression`
- C. `@EnableGzip`
- D. `@EnableDeflate`
- **Answer: B. `@EnableHttpCompression`**

29. What is the correct syntax for defining a custom error page in Spring Boot's
application.properties file?
- A. `error.page=/error`
- B. `error.page.location=/error`
- C. `error.page.redirect=/error`
- D. `error.page.mapping=/error`
- **Answer: A. `error.page=/error`**

30. Which annotation is used to enable HTTP/2 support in a Spring Boot application?
- A. `@EnableHttp2`
- B. `@EnableHttp2Support`
- C. `@EnableHttp2Protocol`
- D. `@EnableHttp2Server`
- **Answer: B. `@EnableHttp2Support`**

31. What is the correct syntax for defining a custom DataSource in Spring Boot's configuration
class?
- A. `@Bean public DataSource dataSource() { }`
- B. `@DataSource public DataSource dataSource() { }`
- C. `@CustomDataSource public DataSource dataSource() { }`
- D. `@DbSource public DataSource dataSource() { }`
- **Answer: A. `@Bean public DataSource dataSource() { }`**

32. Which annotation is used to enable cross-origin resource sharing (CORS) in a Spring Boot
application?
- A. `@EnableCORS`
- B. `@CrossOrigin`
- C. `@AllowOrigin`
- D. `@CorsSupport`
- **Answer: B. `@CrossOrigin`**

33. What is the correct syntax for defining a custom aspect in Spring Boot's configuration class?
- A. `@Aspect public class MyAspect { }`
- B. `@CustomAspect public class MyAspect {

}`
- C. `@Component public class MyAspect { }`
- D. `@AspectJ public class MyAspect { }`
- **Answer: A. `@Aspect public class MyAspect { }`**

34. Which annotation is used to enable distributed tracing in a Spring Boot application?
- A. `@EnableDistributedTracing`
- B. `@EnableTracing`
- C. `@EnableZipkin`
- D. `@EnableSleuth`
- **Answer: D. `@EnableSleuth`**

35. What is the correct syntax for defining a custom Validator in Spring Boot's configuration
class?
- A. `@Bean public MyValidator validator() { }`
- B. `@Validator public MyValidator validator() { }`
- C. `@CustomValidator public MyValidator validator() { }`
- D. `@Validation public MyValidator validator() { }`
- **Answer: A. `@Bean public MyValidator validator() { }`**
36. Which annotation is used to enable HATEOAS support in a Spring Boot application?
- A. `@EnableHateoas`
- B. `@EnableHypermedia`
- C. `@EnableRestSupport`
- D. `@EnableLinkSupport`
- **Answer: A. `@EnableHateoas`**

37. What is the correct syntax for defining a custom event listener in Spring Boot's configuration
class?
- A. `@EventListener public class MyEventListener { }`
- B. `@Listener public class MyEventListener { }`
- C. `@EventSupport public class MyEventListener { }`
- D. `@CustomListener public class MyEventListener { }`
- **Answer: A. `@EventListener public class MyEventListener { }`**

38. Which annotation is used to enable JMS listener container factory in a Spring Boot
application?
- A. `@EnableJms`
- B. `@EnableJmsListeners`
- C. `@EnableJmsContainer`
- D. `@EnableJmsConfiguration`
- **Answer: A. `@EnableJms`**

39. What is the correct syntax for defining a custom message source in Spring Boot's
configuration class?
- A. `@Bean public MessageSource messageSource() { }`
- B. `@MessageSource public MessageSource messageSource() { }`
- C. `@CustomMessageSource public MessageSource messageSource() { }`
- D. `@Source public MessageSource messageSource() { }`
- **Answer: A. `@Bean public MessageSource messageSource() { }`**

40. Which annotation is used to enable Spring Boot's security features in a Spring Boot
application?
- A. `@EnableSecurity`
- B. `@EnableWebSecurity`
- C. `@EnableSecure`
- D. `@EnableAuthentication`
- **Answer: B. `@EnableWebSecurity`*

You might also like