0
0
Spring Bootframework~5 mins

Scheduled tasks with @Scheduled in Spring Boot - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the @Scheduled annotation in Spring Boot?
The @Scheduled annotation is used to mark a method to be executed automatically at fixed intervals or specific times, enabling scheduled tasks in a Spring Boot application.
Click to reveal answer
beginner
How do you enable scheduling support in a Spring Boot application?
You enable scheduling by adding the @EnableScheduling annotation to a configuration class or the main application class.
Click to reveal answer
intermediate
What are the common parameters of the @Scheduled annotation?
Common parameters include fixedRate (runs method at fixed intervals), fixedDelay (runs method after a fixed delay from last completion), and cron (runs method based on a cron expression).
Click to reveal answer
intermediate
Explain the difference between fixedRate and fixedDelay in @Scheduled.
fixedRate runs the method at regular intervals regardless of how long the method takes, while fixedDelay waits until the previous execution finishes and then waits the specified delay before running again.
Click to reveal answer
advanced
What is a cron expression in the context of @Scheduled?
A cron expression is a string that defines a schedule using fields for seconds, minutes, hours, day of month, month, day of week, and optionally year, allowing precise control over when a task runs.
Click to reveal answer
Which annotation must be added to enable scheduling in Spring Boot?
A@EnableScheduling
B@Scheduled
C@EnableAsync
D@EnableTask
What does fixedRate in @Scheduled do?
ARuns the method at fixed intervals regardless of execution time
BRuns the method after a fixed delay from last completion
CRuns the method only once
DRuns the method based on a cron expression
Which parameter of @Scheduled allows scheduling with a cron expression?
AfixedDelay
Bdelay
CfixedRate
Dcron
If you want a method to run 5 seconds after the last execution finishes, which @Scheduled parameter do you use?
AfixedRate = 5000
BfixedDelay = 5000
Ccron = "*/5 * * * * *"
Ddelay = 5000
Where do you place the @Scheduled annotation?
AOn a configuration class
BOn the main application class
COn a method to be scheduled
DOn a field variable
Describe how to set up a scheduled task in Spring Boot using @Scheduled.
Think about enabling scheduling and marking methods.
You got /4 concepts.
    Explain the difference between fixedRate and fixedDelay in scheduling tasks.
    Consider timing relative to method execution.
    You got /2 concepts.