Bird
0
0

Given application.properties contains app.description=Spring Boot App, what will be printed by this code?

medium📝 component behavior Q4 of 15
Spring Boot - Spring Annotations
Given application.properties contains app.description=Spring Boot App, what will be printed by this code?
public class MyApp {
  @Value("${app.description}")
  private String description;

  public void printDesc() {
    System.out.println(description);
  }
}
ASpring Boot App
B${app.description}
Cnull
DCompilation error
Step-by-Step Solution
Solution:
  1. Step 1: Understand @Value injection

    The @Value annotation injects the property value 'Spring Boot App' into the description field.
  2. Step 2: Predict output of printDesc()

    Printing description will output the injected string 'Spring Boot App'.
  3. Final Answer:

    Spring Boot App -> Option A
  4. Quick Check:

    Injected value prints as property value [OK]
Quick Trick: Injected property prints actual value, not the placeholder [OK]
Common Mistakes:
  • Expecting placeholder string instead of value
  • Assuming null if not initialized manually
  • Thinking it causes compile error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes