0
0
Spring Bootframework~10 mins

Feature flags concept in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a feature flag boolean variable in Spring Boot.

Spring Boot
private boolean [1] = true;
Drag options to blanks, or click blank then click option'
AfeatureEnabled
BisActive
CenableFeature
DflagActive
Attempts:
3 left
💡 Hint
Common Mistakes
Using vague variable names that don't indicate a feature flag.
Using non-boolean types for feature flags.
2fill in blank
medium

Complete the code to check if the feature flag is enabled before executing the feature.

Spring Boot
if ([1]) {
    // execute feature code
}
Drag options to blanks, or click blank then click option'
AfeatureFlag
BisFeatureOn
CfeatureActive
DenableFeature
Attempts:
3 left
💡 Hint
Common Mistakes
Using variables that are not declared or unrelated.
Using non-boolean expressions in the if condition.
3fill in blank
hard

Fix the error in the feature flag annotation to enable conditional bean loading.

Spring Boot
@ConditionalOnProperty(name = "[1]", havingValue = "true")
@Bean
public FeatureService featureService() {
    return new FeatureService();
}
Drag options to blanks, or click blank then click option'
Afeature.enabled
BfeatureFlag
CenableFeature
DfeatureActive
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of property keys.
Missing quotes or incorrect property names.
4fill in blank
hard

Fill both blanks to define a feature flag property and inject its value into a Spring component.

Spring Boot
@Value("$[1]")
private boolean [2];
Drag options to blanks, or click blank then click option'
Afeature.enabled
BenableFeature
CfeatureFlag
DisFeatureActive
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing property names and variable names.
Forgetting the ${} syntax around the property.
5fill in blank
hard

Fill all three blanks to create a feature flag configuration class with a default value and getter method.

Spring Boot
public class FeatureConfig {
    @Value("$[1]:[2]")
    private boolean [3];

    public boolean isFeatureEnabled() {
        return [3];
    }
}
Drag options to blanks, or click blank then click option'
Afeature.enabled
Bfalse
CenableFeature
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the default value after the colon.
Using inconsistent variable names between declaration and getter.