Bird
0
0

Which of the following is the correct method signature for a custom initialization method in a Spring bean?

easy📝 Syntax Q3 of 15
Spring Boot - Inversion of Control and Dependency Injection
Which of the following is the correct method signature for a custom initialization method in a Spring bean?
Aprivate void init(String arg)
Bpublic int init()
Cpublic void init()
Dpublic static void init()
Step-by-Step Solution
Solution:
  1. Step 1: Understand initialization method requirements

    Custom init methods must be public, return void, and take no arguments.
  2. Step 2: Check each option's signature

    Only 'public void init()' matches the required signature for Spring init methods.
  3. Final Answer:

    public void init() -> Option C
  4. Quick Check:

    Init method signature = public void no-args [OK]
Quick Trick: Init methods must be public, void, and no-argument [OK]
Common Mistakes:
  • Using private or static methods
  • Returning non-void types
  • Adding parameters to init methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes