Spring Questions and Answers – Implementing and Injecting Beans with Scripting Languages

«
»

This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses on “Implementing and Injecting Beans with Scripting Languages”.

1. Scripting languages supported by Spring?
a) JRuby
b) Groovy
c) BeanShell
d) All of the mentioned
View Answer

Answer: d
Explanation: Spring supports the 3 above mentioned scripting languages.
advertisement

2. Scripting language based on Ruby
a) JRuby
b) Groovy
c) BeanShell
d) All of the mentioned
View Answer

Answer: a
Explanation: JRuby is an open source Java-based implementation of the popular Ruby programming language.

3. Dynamic Language for java platform to cope up with other languages
a) JRuby
b) Groovy
c) BeanShell
d) All of the mentioned
View Answer

Answer: b
Explanation: Groovy is a dynamic language for the Java platform that integrates the features of other excellent programming languages.

4. Lightweight java scripting language executing java fragments
a) JRuby
b) Groovy
c) BeanShell
d) All of the mentioned
View Answer

Answer: c
Explanation: BeanShell is a lightweight Java scripting language that can dynamically execute Java code fragments while supporting scripting features like those of other scripting languages.

5. In Ruby instance variable begins with
a) #
b) *
c) @
d) None of the mentioned
View Answer

Answer: c
Explanation: In Ruby, an instance variable begins with the @ sign.

6. XML Element to declare a bean implemented by JRuby
a) lang:jruby
b) aop:jruby
c) beanscript:jruby
d) script:jruby
View Answer

Answer: a
Explanation: In the bean configuration file, you can declare a bean implemented with JRuby by using the lang:jruby.

advertisement

7. XML element to specify the property values for scripting bean
a) lang:property
b) bean:property
c) script:property
d) None of the mentioned
View Answer

Answer: a
Explanation: You can specify the property values for a scripting bean in the lang:property elements.

8. XML Element to declare a bean implemented by Groovy
a) lang:groovy
b) lang:jruby
c) beanscript:jruby
d) script:jruby
View Answer

Answer: a
Explanation: In the bean configuration file, you can declare a bean implemented with Groovy by using the lang:groovy.

9. Script’s location is specified by attribute
a) script-source
b) xml-source
c) script-annotation
d) none of the mentioned
View Answer

Answer: a
Explanation: Specifying the script’s location in the script-source attribute.

10. XML Element to declare a bean implemented by JRuby
a) lang:bash
b) aop:bash
c) lang:bsh
d) script:bash
View Answer

Answer: c
Explanation: In the bean configuration file, you can declare a bean implemented with BeanShell by using the lang:bsh.

11. Interface used to create additional features in groovy based beans
a) GroovyObjectCustomizer
b) GroovyBeanCustomizer
c) GroovyCustomizer
d) None of the mentioned
View Answer

Answer: a
Explanation: The GroovyObjectCustomizer interface is a callback that allows you to hook additional creation logic into the process of creating a Groovy-backed bean.

12. Attribute which specifies all the interfaces
a) script-interfaces
b) lang:bsh
c) lang:script
d) script:bsh
View Answer

Answer: a
Explanation: Spring creates a JDK dynamic proxy implementing all of the interfaces that are specified in the ‘script-interfaces’.
advertisement

13. Class-based proxies are best way to advise scripted beans
a) True
b) False
View Answer

Answer: b
Explanation: There is just one (small) thing that you need to be aware of when advising scripted beans. You cannot use class-based proxies, you must use interface-based proxies.

14. Element which allows you to control the scope
a) lang:jruby
b) lang:language
c) lang: bsh
d) lang:groovy
View Answer

Answer: b
Explanation: The scope attribute on the various lang:language/ elements allows you to control the scope of the underlying scripted bean, just as it does with a regular bean.

15. BeanShell Library dependencies
a) bsh-2.0b4.jar
b) cglib-nodep-2.1_3.jar
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: c
Explanation: All of these libraries are available in the Spring-with-dependencies distribution of Spring (in addition to also being freely available on the web).

Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn