Bird
0
0

Identify the error in this Spring Boot feature flag usage:

medium📝 Debug Q14 of 15
Spring Boot - Advanced Patterns
Identify the error in this Spring Boot feature flag usage:
@GetMapping("/feature")
public String feature() {
    if(featureFlagService.isFeatureEnabled) {
        return "Feature ON";
    } else {
        return "Feature OFF";
    }
}
AReturn type should be void
BIncorrect HTTP method annotation
CMissing parentheses when calling isFeatureEnabled method
DFeature flag service not injected
Step-by-Step Solution
Solution:
  1. Step 1: Check method call syntax

    isFeatureEnabled is a method and must be called with parentheses ().
  2. Step 2: Verify other code parts

    HTTP annotation and return type are correct; no injection info given but not error here.
  3. Final Answer:

    Missing parentheses when calling isFeatureEnabled method -> Option C
  4. Quick Check:

    Method calls need () [OK]
Quick Trick: Method calls always need parentheses () [OK]
Common Mistakes:
  • Forgetting () after method names
  • Confusing HTTP method annotations
  • Assuming return type must be void

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes