Question 1
Which TWO statements about activating Spring profiles are correct? Select TWO.
A. Several profiles can be active at once, e.g. spring.profiles.active=dev,db-h2Correct answer
Spring places no limit on the number of active profiles; several are commonly activated together as a comma-separated list in spring.profiles.active.
B. Profiles can be activated programmatically, e.g. environment.setActiveProfiles("dev", "db-h2")Correct answer
Besides property-based activation, profiles can be set in code by calling Environment.setActiveProfiles(...) before the context refreshes, which likewise accepts one or more profile names.
C. Exactly one profile may be active at a time
There is no single-active-profile limit in Spring; several profiles may be active simultaneously, so restricting activation to exactly one is wrong.
D. At most two profiles can be active
Spring imposes no cap of two active profiles; the number of simultaneously active profiles is unbounded.
Explanation
Spring places no limit on how many profiles may be active at the same time. They are commonly activated together as a comma-separated list via the spring.profiles.active property, and they can equally be activated in code by calling Environment.setActiveProfiles(...) before the context is refreshed. Claims that only one profile, or at most two, may be active are simply false.