Bird
0
0

Why does Spring Boot require the @Scheduled methods to be non-private and void-returning?

hard📝 Conceptual Q10 of 15
Spring Boot - Async Processing
Why does Spring Boot require the @Scheduled methods to be non-private and void-returning?
ABecause Spring uses proxies that require public void methods to schedule tasks
BBecause private methods cannot be called by Spring and return values are ignored
CBecause scheduled methods must be static and void to run in background
DBecause Spring only supports void methods with no parameters
Step-by-Step Solution
Solution:
  1. Step 1: Understand Spring proxy limitations

    Spring uses proxies that cannot intercept private methods, so methods must be non-private.
  2. Step 2: Understand return type relevance

    Return values from scheduled methods are ignored, so void is recommended.
  3. Final Answer:

    Private methods cannot be called by Spring and return values are ignored -> Option B
  4. Quick Check:

    Non-private needed for proxy, return ignored = B [OK]
Quick Trick: Scheduled methods must be non-private; return values ignored [OK]
Common Mistakes:
  • Thinking methods must be static
  • Expecting return values from scheduled methods
  • Using private methods for scheduling

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes