Bird
0
0

Why is the question mark (?) required in either the day-of-month or day-of-week field in Spring Boot cron expressions?

hard📝 Conceptual Q10 of 15
Spring Boot - Async Processing
Why is the question mark (?) required in either the day-of-month or day-of-week field in Spring Boot cron expressions?
ABecause specifying both fields causes ambiguity in scheduling
BBecause ? means 'run every day' and is mandatory
CBecause ? disables the scheduler temporarily
DBecause ? is used to specify the year field
Step-by-Step Solution
Solution:
  1. Step 1: Understand day-of-month and day-of-week fields

    In cron, day-of-month and day-of-week fields can both specify when to run, but if both are set, it can cause conflicts or ambiguity.
  2. Step 2: Role of question mark

    The question mark (?) is used in one of these fields to say 'no specific value' to avoid ambiguity, ensuring the scheduler knows which field to use.
  3. Final Answer:

    Because specifying both fields causes ambiguity in scheduling -> Option A
  4. Quick Check:

    Use ? to avoid day-of-month/day-of-week conflict [OK]
Quick Trick: Use ? in one day field to avoid ambiguity [OK]
Common Mistakes:
  • Thinking ? means run every day
  • Using ? in wrong fields
  • Confusing ? with *

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes