0
0
Spring Bootframework~20 mins

@EnableAsync annotation in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Async Mastery in Spring Boot
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when @EnableAsync is added to a Spring Boot configuration?
Consider a Spring Boot application where the @EnableAsync annotation is added to a configuration class. What is the effect of this annotation on the application's behavior?
AIt disables all asynchronous processing in the application.
BIt enables the processing of methods annotated with @Async to run asynchronously in a separate thread.
CIt automatically schedules all methods to run at fixed intervals.
DIt converts all synchronous methods into reactive streams.
Attempts:
2 left
💡 Hint
Think about what @Async methods need to work properly in Spring.
📝 Syntax
intermediate
2:00remaining
Identify the correct way to enable async processing in Spring Boot
Which of the following code snippets correctly enables asynchronous method execution in a Spring Boot application?
Spring Boot
public class AppConfig {
    // ...
}
A
@Configuration
@EnableAsync(true)
public class AppConfig {}
B
@EnableAsync
public class AppConfig {}
C
@Configuration
@EnableAsync()
public class AppConfig {}
D
@Configuration
@EnableAsync
public class AppConfig {}
Attempts:
2 left
💡 Hint
Remember that @EnableAsync is a meta-annotation and usually combined with @Configuration.
🔧 Debug
advanced
2:00remaining
Why does @Async not work despite @EnableAsync being present?
A developer added @EnableAsync to their Spring Boot configuration but notices that methods annotated with @Async still run synchronously. What is the most likely cause?
AThe @Async method is called from within the same class, bypassing Spring's proxy mechanism.
BThe @EnableAsync annotation must be placed on the main application class only.
CThe @Async annotation requires a special bean name to work.
DSpring Boot disables @Async by default even with @EnableAsync.
Attempts:
2 left
💡 Hint
Think about how Spring proxies work with self-invocation.
state_output
advanced
2:00remaining
What thread name prefix is used by default for @Async methods?
When a method annotated with @Async runs, what is the default prefix of the thread name executing it?
ASimpleAsyncTaskExecutor-
BThreadPoolTaskExecutor-
CAsyncExecutor-
DDefaultAsyncThread-
Attempts:
2 left
💡 Hint
Look at the default executor Spring uses if none is configured.
🧠 Conceptual
expert
3:00remaining
How does @EnableAsync affect Spring's proxy creation and bean lifecycle?
Which statement best describes the impact of @EnableAsync on Spring's proxy creation and bean lifecycle?
A@EnableAsync replaces all beans with asynchronous versions at runtime without using proxies.
B@EnableAsync delays bean initialization until the first @Async method is called.
C@EnableAsync triggers Spring to create proxies for beans with @Async methods, enabling asynchronous execution by intercepting method calls.
D@EnableAsync disables Spring's default proxy mechanism to allow direct thread spawning.
Attempts:
2 left
💡 Hint
Consider how Spring intercepts method calls to add behavior.