Bird
0
0

Which of the following is the correct syntax to schedule a method to run every 10 seconds using @Scheduled annotation?

easy📝 Syntax Q3 of 15
Spring Boot - Async Processing
Which of the following is the correct syntax to schedule a method to run every 10 seconds using @Scheduled annotation?
A@Scheduled(cron = "*/10 * * * * *")
B@Scheduled(fixedRate = "10000")
C@Scheduled(fixedDelay = 10000)
D@Scheduled(fixedDelay = "10s")
Step-by-Step Solution
Solution:
  1. Step 1: Check valid syntax for every 10 seconds

    The cron "*/10 * * * * *" uses the seconds field to run every 10 seconds (0,10,20,30,40,50).
  2. Step 2: Validate each option

    B: quoted string for fixedRate (invalid). C: fixedDelay=10000 delays after method ends (not fixed interval every 10s). D: invalid format. A is correct.
  3. Final Answer:

    @Scheduled(cron = "*/10 * * * * *") is correct syntax -> Option A
  4. Quick Check:

    Cron */10 * * * * * = every 10s = A [OK]
Quick Trick: Use numbers without quotes for fixedRate/fixedDelay [OK]
Common Mistakes:
  • Putting numbers in quotes for fixedRate/fixedDelay
  • Using invalid cron syntax for seconds
  • Using unsupported time units like "10s"

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes