0
0
Spring Bootframework~20 mins

Feature flags concept in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Feature Flags Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
How does a feature flag affect Spring Boot application behavior?
Consider a Spring Boot app with a feature flag controlling a new payment method. What happens when the flag is OFF?
Spring Boot
public boolean isNewPaymentEnabled() {
    return featureFlagService.isEnabled("newPayment");
}

if (isNewPaymentEnabled()) {
    // use new payment method
} else {
    // use old payment method
}
AThe app uses the old payment method only.
BThe app uses both old and new payment methods simultaneously.
CThe app throws an error because the feature flag is off.
DThe app disables all payment methods.
Attempts:
2 left
💡 Hint
Think about what the flag controls and what happens when it is false.
📝 Syntax
intermediate
1:30remaining
Which code snippet correctly checks a feature flag in Spring Boot?
You want to check if a feature flag named "betaFeature" is enabled using a FeatureFlagService. Which option is correct?
Aif (featureFlagService.isEnable("betaFeature")) { /* enabled */ }
Bif (featureFlagService.enabled("betaFeature")) { /* enabled */ }
Cif (featureFlagService.isEnabled("betaFeature")) { /* enabled */ }
Dif (featureFlagService.check("betaFeature")) { /* enabled */ }
Attempts:
2 left
💡 Hint
Look for the common naming pattern for boolean checks in Java.
state_output
advanced
2:30remaining
What is the output when toggling a feature flag at runtime?
Given a Spring Boot app where a feature flag "darkMode" is initially OFF, what happens if you enable it at runtime and then reload the page?
Spring Boot
boolean darkMode = featureFlagService.isEnabled("darkMode");
System.out.println("Dark mode enabled: " + darkMode);
APrints true initially and false after reload.
BAlways prints false because flags can't change at runtime.
CThrows an exception when toggling the flag.
DFirst prints false, then after enabling and reload, prints true.
Attempts:
2 left
💡 Hint
Feature flags can be dynamic if implemented properly.
🔧 Debug
advanced
3:00remaining
Why does the feature flag check always return false?
You wrote this code but the feature flag check always returns false even when enabled: @Service public class FeatureFlagService { private Map flags = Map.of("newUI", false); public boolean isEnabled(String flag) { return flags.getOrDefault(flag, false); } } What is the likely cause?
AThe flags map is immutable and never updated after initialization.
BThe isEnabled method has a typo in the flag name.
CThe service is not annotated with @Component.
DThe flags map keys are case sensitive and mismatched.
Attempts:
2 left
💡 Hint
Think about how Map.of works in Java.
🧠 Conceptual
expert
2:00remaining
What is the main benefit of using feature flags in Spring Boot applications?
Choose the best explanation for why developers use feature flags in Spring Boot projects.
AThey automatically fix bugs in the code at runtime.
BThey allow turning features on or off without redeploying the app.
CThey improve database query performance by caching results.
DThey replace the need for unit testing by isolating features.
Attempts:
2 left
💡 Hint
Think about how feature flags help with releasing new features safely.