0% found this document useful (0 votes)
20 views

Spring Boot MCQ

Uploaded by

sriraksha1431
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Spring Boot MCQ

Uploaded by

sriraksha1431
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

5/18/24, 12:08 AM Spring Boot MCQ

All Posts

Spring Boot MCQ


31 March 2024 | MCQ

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**

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 1/28
5/18/24, 12:08 AM Spring Boot MCQ

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?


This- A.website
By providinguses cookies.
built-in support for Maven
- B. cookies
We use By automatically
to analyzeresolving
website version conflicts
traffic and optimize your website experience. By accepting
- C.of
our use Bycookies,
providing a graphical
your interface
data will be for dependency
aggregated management
with all other user data.
- D. By using XML configuration files
- **Answer: B. By automatically resolving version conflicts**
ACCEPT
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

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 2/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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
This- **Answer:
websiteD.uses cookies.
All of the above**
We12.
useWhat
cookies to analyze
is Spring Boot website
Actuatortraffic
used and
for? optimize your website experience. By accepting
our use
- A.ofTocookies, your dataweb
create RESTful will services
be aggregated with all other user data.
- B. To monitor and manage Spring Boot applications
- C. To handle security configurations A C C E P T
- 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**

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 3/28
5/18/24, 12:08 AM Spring Boot MCQ

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?


This- A.
website uses
To run tasks cookies.
before the application starts up
- B.cookies
We use To define command-line
to analyze websitearguments
traffic andfor the application
optimize your website experience. By accepting
- C.ofTo
our use handle your
cookies, HTTP requests
data will beand responses
aggregated with all other user data.
- D. To create RESTful web services
- **Answer: A. To run tasks before the application starts up**
ACCEPT
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

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 4/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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
This- D.
website uses cookies.
All of the above
- **Answer:
We use A.analyze
cookies to To conditionally enableand
website traffic components based
optimize your on certain
website conditions**
experience. By accepting
our 25.
useHow
of cookies, your data
does Spring Bootwill be aggregated
handle with
externalized all other user data.
configuration?
- A. By providing properties files outside the application JAR
- B. By using environment variables A C C E P T
- 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**

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 5/28
5/18/24, 12:08 AM Spring Boot MCQ

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?
This- A.
website uses
By providing cookies.
built-in support for JDBC
- B.cookies
We use By automatically
to analyzeconfiguring datasource
website traffic beansyour website experience. By accepting
and optimize
- C.ofBy
our use generating
cookies, your SQL
data queries from entity classes
will be aggregated with all other user data.
- D. All of the above
- **Answer: D. All of the above**
ACCEPT
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

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 6/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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
This- **Answer:
websiteD.uses cookies.
All of the above**
We38.
useWhat
cookies to analyze
is the purpose website
of Springtraffic
Boot'sand optimize your website experience.annotation?
@EnableTransactionManagement By accepting
our use
- A.ofTocookies,
enable your data will
transaction be aggregated with all other user data.
management
- B. To enable caching
- C. To enable scheduling ACCEPT
- 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

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 7/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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
This- **Answer:
website uses
B. To cookies.
define request mapping for controller methods**
We4.useHowcookies
does to analyze
Spring Bootwebsite
simplifytraffic andconfiguration?
security optimize your website experience. By accepting
our use
- A. of
Bycookies, your
providing datasupport
built-in will be aggregated
for OAuth with all other user data.
- B. By generating security configurations based on user roles
- C. By providing annotations like @EnableWebSecurity
ACCEPT
- 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

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 8/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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
This- C.
website uses generating
By automatically cookies.client code
- D.cookies
We use By providing built-in
to analyze support
website for Apache
traffic HttpClient
and optimize your website experience. By accepting
- **Answer:
our use B. your
of cookies, By using
data the
will RestTemplate
be aggregatedclass**
with all other user data.
11. What is the purpose of Spring Boot's @Validated annotation?
- A. To validate form inputs in web applications
ACCEPT
- 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**

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 9/28
5/18/24, 12:08 AM Spring Boot MCQ

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?


This- A.
website
To specify uses cookies.
the origin of incoming HTTP requests
- B.cookies
We use To enable cross-origin
to analyze resource
website traffic sharing (CORS)
and optimize your website experience. By accepting
our use
- C.ofTo
cookies, your
configure data willconnections
database be aggregated with all other user data.
- D. To define URL patterns for static resources
- **Answer: B. To enable cross-origin Aresource
C C E P T 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

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 10/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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
This- **Answer:
websiteA. uses cookies.
To enable transaction management**
We24.
useHow
cookies
doestoSpring
analyze website
Boot simplifytraffic
the and optimize
creation your website
of scheduled experience. By accepting
tasks?
our use
- A.ofBy
cookies, your
providing data will be
annotations aggregated
like @Scheduled with all other user data.
- B. By generating code based on configuration
- C. By automatically configuring task Aschedulers
CCEPT
- 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

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 11/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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
This- C.
website uses
By supporting cookies.
message interpolation
- D.cookies
We use All of the
to above
analyze website traffic and optimize your website experience. By accepting
- **Answer:
our use of cookies,D. your
All ofdata
the above**
will be aggregated with all other user data.
31. What is the purpose of Spring Boot's @Async annotation?
- A. To enable asynchronous processingACCofEmethod
PT 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**

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 12/28
5/18/24, 12:08 AM Spring Boot MCQ

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**
This website uses cookies.
37. What is the purpose of Spring Boot's @WebMvcTest annotation?
We use
- A.cookies to analyze
To enable website
integration traffic
testing and optimize
of Spring your website experience. By accepting
MVC controllers
our use
- B.ofTocookies, your data
define request will be aggregated
mapping for controllerwith all other user data.
methods
- C. To enable component scanning for web applications
- D. To specify the base URL for RESTful
A C Cendpoints
EPT
- **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

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 13/28
5/18/24, 12:08 AM Spring Boot MCQ

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**
This website
3. What uses ofcookies.
is the purpose Spring Boot's Actuator module?
- A. cookies
We use To enable cross-origin
to analyze resource
website trafficsharing (CORS)
and optimize your website experience. By accepting
- B.of
our use Tocookies,
monitor your
and manage
data will Spring Boot applications
be aggregated with all other user data.
- C. To provide authentication and authorization mechanisms
- D. To automate deployment processes
ACCEPT
- **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
https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 14/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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
This- D.website uses
By extending cookies. class
the ResponseEntity
- **Answer:
We use cookies A. By providing
to analyze a custom
website exception
traffic and handler
optimize with @ControllerAdvice**
your website experience. By accepting
our 10.
useWhich
of cookies, your data
annotation will to
is used beenable
aggregated with all
distributed other in
tracing user data.Boot applications?
Spring
- A. @EnableDistributedTracing
- B. @EnableZipkinTracing ACCEPT
- 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**

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 15/28
5/18/24, 12:08 AM Spring Boot MCQ

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**
This website uses cookies.
16. How can you configure an embedded Tomcat server to use a custom SSL certificate
Weinuse cookiesBoot
a Spring to analyze website traffic and optimize your website experience. By accepting
application?
our use
- A.ofBy
cookies, your server.ssl
configuring data will be aggregated
properties with all other user data.
in application.properties
- B. By providing a keystore file and configuring server.ssl properties
- C. By using the @EnableSsl annotation
ACCEPT
- 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**

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 16/28
5/18/24, 12:08 AM Spring Boot MCQ

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?


This- A.
website
To enable uses cookies.
asynchronous processing of method calls
- B.cookies
We use To define asynchronous
to analyze websiteRESTful endpoints
traffic and optimize your website experience. By accepting
- C.ofTo
our use schedule
cookies, asynchronous
your tasks
data will be aggregated with all other user data.
- D. To enable asynchronous database transactions
- **Answer: A. To enable asynchronous processing of method calls**
ACCEPT
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
https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 17/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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
This- **Answer:
websiteD.uses cookies.
By configuring authentication beans in a @Configuration class**
We29.
useWhich
cookies to analyze
annotation is website traffic and
used to enable optimize
HTTP/2 yourinwebsite
support experience.
a Spring By accepting
Boot application?
our use
- A.of@EnableHttp2
cookies, your data will be aggregated with all other user data.
- B. @EnableHttp2Support
- C. @EnableHttp2Protocol ACCEPT
- 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**

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 18/28
5/18/24, 12:08 AM Spring Boot MCQ

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**
This website uses cookies.
35. How can you customize the JSON serialization format for specific properties in a
WeSpring
use cookies to analyze website traffic and optimize your website experience. By accepting
Boot application?
our use
- A.ofBy
cookies, your data
using custom will be aggregated
serializers with
with Jackson all other user data.
ObjectMapper
- B. By providing serialization properties in application.properties
- C. By using annotations like @JsonFormat
ACCEPT
- 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

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 19/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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


This website uses cookies.
We1.useWhat is thetocorrect
cookies analyzesyntax for traffic
website defining a Spring
and Boot
optimize yourapplication class?
website experience. By accepting
- A. of
our use `@SpringBootApplication
cookies, your data will beclass MyApp {with
aggregated }` all other user data.
- B. `class MyApp { }`
- C. `@SpringBootApp class MyApp { }`
ACCEPT
- 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")`

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 20/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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> {
}`**
This website
6. Which uses
annotation cookies.
is used to specify the primary bean among multiple candidates of
Wethe
usesame type?
cookies to analyze website traffic and optimize your website experience. By accepting
- A. of
our use `@Primary`
cookies, your data will be aggregated with all other user data.
- B. `@Main`
- C. `@First`
ACCEPT
- 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() { }`**

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 21/28
5/18/24, 12:08 AM Spring Boot MCQ

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() { }`**
This
12. website usesis cookies.
Which annotation used to enable Spring Boot's TestRestTemplate for integration
Wetesting?
use cookies to analyze website traffic and optimize your website experience. By accepting
- A.of`@EnableTestRestTemplate`
our use cookies, your data will be aggregated with all other user data.
- B. `@EnableRestTemplateTest`
- C. `@RestTemplateTest`
ACCEPT
- 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`**

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 22/28
5/18/24, 12:08 AM Spring Boot MCQ

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}`
This- D.
website uses cookies.
`{my.property=value}`
- **Answer:
We use A.analyze
cookies to `my.property=value`**
website traffic and optimize your website experience. By accepting
our 18.
useWhich
of cookies, your data
annotation will to
is used bedefine
aggregated witherror
a custom all other userfor
handler data.
a specific exception
type in Spring Boot?
- A. `@ExceptionHandler` ACCEPT
- 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 { }`

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 23/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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`
This- C.
website uses cookies.
`active.profile=my-profile`
- D.cookies
We use `profile=my-profile`
to analyze website traffic and optimize your website experience. By accepting
- **Answer:
our use A. your
of cookies, `spring.profiles.active=my-profile`**
data will be aggregated with all other user data.
24. Which annotation is used to specify the base package for component scanning in a
Spring Boot application? ACCEPT
- 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() { }`
https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 24/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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`
This- C.
website uses cookies.
`error.page.redirect=/error`
- D.cookies
We use `error.page.mapping=/error`
to analyze website traffic and optimize your website experience. By accepting
- **Answer:
our use A. your
of cookies, `error.page=/error`**
data will be aggregated with all other user data.
30. Which annotation is used to enable HTTP/2 support in a Spring Boot application?
- A. `@EnableHttp2` ACCEPT
- 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 {

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 25/28
5/18/24, 12:08 AM Spring Boot MCQ

}`
- 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() { }`
This- B.
website uses
`@Validator publiccookies.
MyValidator validator() { }`
- C.cookies
We use `@CustomValidator public traffic
to analyze website MyValidator validator()
and optimize your{ website
}` experience. By accepting
- D.of`@Validation
our use cookies, yourpublic
data MyValidator validator()
will be aggregated with{all
}` other user data.
- **Answer: A. `@Bean public MyValidator validator() { }`**

36. Which annotation is used to enable AHATEOAS


C C E P T 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() { }`
https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 26/28
5/18/24, 12:08 AM Spring Boot MCQ

- 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`**

Share this post:

This website uses cookies.


Categories
We use cookies to analyze website traffic and optimize your website experience. By accepting
our use of cookies, your data will be aggregated with all other user data.
All Posts

MCQ ACCEPT

Sign up for blog updates!


Join my email list to receive updates and information.

Email address

SIGN UP

Recent Posts
Python MCQ

31 Mar 2024

Django MCQ

31 Mar 2024

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 27/28
5/18/24, 12:08 AM Spring Boot MCQ

Java MCQ

31 Mar 2024

COPYRIGHT © 2024 - ALL RIGHTS RESERVED.

This website uses cookies.


We use cookies to analyze website traffic and optimize your website experience. By accepting
POWERED BY GODADDY
our use of cookies, your data will be aggregated with all other user data.

ACCEPT

https://affilino.godaddysites.com/mcq/f/spring-boot-mcq 28/28

You might also like