Java Spring Multiple Choice Questions & Answers (MCQs) on “Refreshing and Defining Beans from Scripts”.
1. Attribute used by Spring to refresh beans
a) refresh-check-interval
b) refresh-check-delay
c) refresh-delay
d) none of the mentioned
Answer: b
Clarification: Spring is able to refresh a scripted bean definition from its source once you have specified the checking interval in the refresh-check-delay attribute.
2. Spring IoC container refreshes the script periodically according to the interval period specified
a) True
b) False
Answer: a
Clarification: When a method is called on that bean, Spring will check the script source if the specified checking interval has elapsed. The Spring will refresh the bean definition from the script source if it has been changed.
3. Default value of refresh-check-delay attribute
a) Zero
b) Negative
c) Positive
d) None of the mentioned above
Answer: b
Clarification: By default, the refresh-check-delay attribute is negative, so the refresh checking feature is disabled. You can assign the milliseconds for refresh checking in this attribute to enable this feature.
4. XML Element to define an inline script
a) lang:inlinescript
b) lang:inline_script
c) lang:[email protected]
d) lang:inline-script
Answer: d
Clarification: You can define an inline script source in the lang:inline-script element of a scripted bean to replace a reference to an external script source file by the script-source attribute.
5. Refresh checking feature is not applicable for an inline script
a) True
b) False
Answer: a
Clarification: Spring IoC container only loads the bean configuration once, at startup.
6. To prevent the characters in your script from conflicting with the reserved XML characters
a) Use ![CDATA[…]] tag
b) Use ![DATA[…]] tag
c) Use ![CDATA(…)] tag
d) None of the mentioned
Answer: a
Clarification: You no longer have to specify the reference to the external script source file in the script-source attribute.
7. Dynamic-language-backed bean with some configurations
a) Refreshable bean
b) Beanshell
c) Scripting Beans
d) Inline Script
Answer: a
Clarification: A refreshable bean is a dynamic-language-backed bean that with a small amount of configuration, a dynamic-language-backed bean can monitor changes in its underlying source file resource, and then reload itself when the dynamic language source file is changed.
8. To quickly add a Spring Validator implementation to a Spring MVC Controller
a) Use inline-script
b) lang:inline-script
c) All of the mentioned
d) None of the mentioned
Answer: c
Clarification: If we put to one side the issues surrounding whether it is good practice to define dynamic language source inside a Spring configuration file, the lang:inline-script/ element can be useful in some scenarios.
9. Spring can detect and refresh changes from the script source files
a) True
b) False
Answer: a
Exlanation: Using Refreshing Inline script.
10. Script’s location is specified by attribute
a) script-source
b) xml-source
c) script-annotation
d) none of the mentioned
Answer: a
Clarification: Specifying the script’s location in the script-source attribute.