Bird
0
0

Given the following Spring Boot code snippet, what will be the output if the feature flag "betaFeature" is disabled?

medium📝 component behavior Q13 of 15
Spring Boot - Advanced Patterns
Given the following Spring Boot code snippet, what will be the output if the feature flag "betaFeature" is disabled?
if(featureFlagService.isFeatureEnabled("betaFeature")) {
    System.out.println("Beta feature is ON");
} else {
    System.out.println("Beta feature is OFF");
}
ABeta feature is ON
BBeta feature is OFF
CNo output
DRuntime error
Step-by-Step Solution
Solution:
  1. Step 1: Understand the condition check

    The code prints "Beta feature is ON" only if the flag is enabled (true).
  2. Step 2: Analyze the flag state given

    The flag "betaFeature" is disabled, so isFeatureEnabled returns false, triggering the else block.
  3. Final Answer:

    Beta feature is OFF -> Option B
  4. Quick Check:

    Flag disabled = else block runs [OK]
Quick Trick: Disabled flag triggers else block output [OK]
Common Mistakes:
  • Assuming disabled flag prints ON message
  • Expecting no output when else block exists
  • Thinking code throws error on false flag

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes