Spring Boot Asynchronous Processing with @Async: Basics
Learn the fundamentals of asynchronous processing in Spring Boot using the @Async annotation.
Questions in this quiz
15 questions on Spring Boot Asynchronous Processing with @Async: Basics. Work through them here, then start the quiz to answer them and see your score.
1.What is the primary purpose of the @Async annotation in Spring Boot?
- ATo manage transactions
- BTo enable caching
- CTo run methods asynchronously
- DTo handle exceptions
2.Which Spring Boot component is typically required to enable @Async functionality?
- A@EnableScheduling
- B@EnableTransactionManagement
- C@EnableCaching
- D@EnableAsync
3.What return type should a method annotated with @Async have to handle results asynchronously?
- Avoid
- Bint
- CFuture or CompletableFuture
- DString
4.Where should the @Async annotation be placed in a Spring Boot application?
- AOn the method level
- BOn the package level
- COn the variable level
- DOn the class level
5.What is the default executor used by Spring Boot for @Async methods if none is specified?
- AThreadPoolTaskExecutor
- BScheduledThreadPoolExecutor
- CForkJoinPool
- DSimpleAsyncTaskExecutor
6.How can you specify a custom executor for @Async methods in Spring Boot?
- ABy configuring a bean of type Executor
- BBy using @AsyncExecutor
- CBy setting a property in application.properties
- DBy using @CustomExecutor
7.What happens if an exception is thrown in an @Async method?
- AIt is wrapped in an ExecutionException
- BIt is ignored
- CIt is logged
- DIt is thrown to the caller
8.Which of the following is NOT a valid return type for an @Async method?
- AFuture<String>
- Bvoid
- CCompletableFuture<Integer>
- DList<String>
9.Can @Async methods be called from within the same class?
- ANo, never
- BYes, but only if the method is public
- CYes, but only if called through a proxy
- DYes, always
10.Which annotation is used to define a method as a bean that returns an executor?
- A@Configuration
- B@Component
- C@Bean
- D@Service
11.What is the effect of using @Async on a method that returns void?
- AThe method runs asynchronously
- BThe method cannot be annotated with @Async
- CThe method runs synchronously
- DThe method throws an error
12.How does Spring Boot handle the execution of multiple @Async methods by default?
- AIn parallel using multiple threads
- BUsing a fixed thread pool
- CSequentially
- DUsing a single thread
13.What is a common use case for using @Async in a Spring Boot application?
- ATo perform long-running tasks without blocking
- BTo manage application configuration
- CTo handle synchronous database transactions
- DTo handle user authentication
14.What should you do if you need to handle exceptions from an @Async method?
- AUse a custom exception handler
- BHandle exceptions in the caller method
- CExceptions cannot be handled
- DUse a try-catch block inside the method
15.Which of the following methods can be used to check if an @Async task is complete?
- AisExecuted()
- BisFinished()
- CisDone()
- DisComplete()