Exam 2v0-7222 All QuestionsBrowse all questions from this exam
Question 2

Which two options will inject the value of the daily.limit system property? (Choose two.)

    Correct Answer: D, E

    To inject the value of a system property in Spring, you can use Spring Expression Language (SpEL) syntax. The correct options are #{systemProperties['daily.limit']} and #{systemProperties.daily.limit} as these correctly refer to the system properties. Option D uses #{systemProperties['daily.limit']} which is a correct form and Option E uses #{systemProperties.daily.limit} which is a more simplified but valid form. Other syntaxes like $(...) or #{} without properly referencing systemProperties are not valid for this purpose.

Discussion
rhuancaOptions: AE

A. @Value(“#{daily.limit}”) E. @Value(“#{systemProperties.daily.limit}”) because we are talking about SystemProperty

Tolo01Option: D

Only D is the correct answer

Azuni

I also realized this now. The way the question is formulated, B and C, has () and not {}. Only D will work. If the () in B and C were changed to {}, then C and D will be correct.

GlothanOptions: DE

The C is not for systemproperties but only for application properties. In the exam the "(" are replaced by "{". Correct answers are DE

AzuniOptions: CD

This question appeared on my exam. There is an error on the answers. Answer C is different than in the exam. The text in the exam is @Value(“${daily.limit}”).

qqooOptions: CD

Answer is CD

Azuni

I tested all scenarios on my own IDE and it confirms your answer that it is C and D.

Evoila_TrainingMaterialOptions: CD

Correct Choices: Option C: @Value("${daily.limit}") Option D: @Value("#{systemProperties['daily.limit']}") These two options correctly inject the value of the daily.limit system property. Incorrect Choices Explanation: Option A: @Value("#{daily.limit}") This syntax is incorrect because it looks for a bean named daily.limit in the Spring context, not a system property. Option B: @Value("$(systemProperties.daily.limit)") This is incorrect because the $(...) syntax is not valid in Spring's @Value annotation. Option E: @Value("#{systemProperties.daily.limit}") This is incorrect because the correct SpEL syntax requires the use of ['...'] for accessing properties dynamically.

Evoila_TrainingMaterialOptions: CD

Correct Choices: Option C: @Value("${daily.limit}") Option D: @Value("#{systemProperties['daily.limit']}") These two options correctly inject the value of the daily.limit system property. Incorrect Choices Explanation: Option A: @Value("#{daily.limit}") This syntax is incorrect because it looks for a bean named daily.limit in the Spring context, not a system property. Option B: @Value("$(systemProperties.daily.limit)") This is incorrect because the $(...) syntax is not valid in Spring's @Value annotation. Option E: @Value("#{systemProperties.daily.limit}") This is incorrect because the correct SpEL syntax requires the use of ['...'] for accessing properties dynamically.

james2033

Probably, the question is incorrect. Correct way of Spring Express language like this https://docs.spring.io/spring-framework/docs/3.0.x/reference/expressions.html value="#{ systemProperties['user.region'] }" and/or value="#{ numberGuess.randomNumber }" and/or @Value("#{ systemProperties['user.region'] }") private String defaultLocale;

GlothanOptions: BD

The C is not for systemproperties but only for application properties. In the exam the "(" are replaced by "{". Correct answers are BD