250+ TOP MCQs on Implementing and Injecting Beans with Scripting Languages and Answers

Java Spring Multiple Choice Questions & Answers (MCQs) 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
Answer: d
Clarification: Spring supports the 3 above mentioned scripting languages.

2. Scripting language based on Ruby
a) JRuby
b) Groovy
c) BeanShell
d) All of the mentioned
Answer: a
Clarification: 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
Answer: b
Clarification: 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
Answer: c
Clarification: 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
Answer: c
Clarification: 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
Answer: a
Clarification: In the bean configuration file, you can declare a bean implemented with JRuby by using the lang:jruby.

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
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: c
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: Spring creates a JDK dynamic proxy implementing all of the interfaces that are specified in the ‘script-interfaces’.

13. Class-based proxies are best way to advise scripted beans
a) True
b) False
Answer: b
Clarification: 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
Answer: b
Clarification: 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
Answer: c
Clarification: All of these libraries are available in the Spring-with-dependencies distribution of Spring (in addition to also being freely available on the web).

Leave a Reply

Your email address will not be published. Required fields are marked *