Groovy(Engineering > Computer Science And Engineering ) Questions and Answers

Question 1. How Groovy string is expressed?
  1.    It is surrounded by double quotes, for regular strings it uses single quotes
  2.    It may contain Groovy Expressions noted in ${}
  3.    Square bracket syntax may be applied like charAt(i)
  4.    All of these
Explanation:-
Answer: Option D. -> All of these





Question 2. How Groovy string is expressed?
  1.    It is surrounded by double quotes, for regular strings it uses single quotes
  2.    It may contain Groovy Expressions noted in ${}
  3.    Square bracket syntax may be applied like charAt(i)
  4.    All of these
Explanation:-
Answer: Option D. -> All of these





Question 3. What is the limitation of Groovy?
  1.    Groovy can be slower
  2.    Groovy might need lots of memory
  3.    Groovy start up time requires improvement
  4.    All of the above
Explanation:-
Answer: Option D. -> All of the above





Question 4. You write a web application with groovlets. You need to get parameter of the request with name 'age' in your script. What is the best way to do this?
  1.    def age = params.age ?: 0
  2.    def age = params.age ? params.age : 0
  3.    def age = params.name == 'age' ? params.age : "not found"
  4.    def age = params.getAge
Explanation:-
Answer: Option D. -> def age = params.getAge





Question 5. How can we build AST (Abstract Syntax Trees) in Groovy from string?
  1.    Strings
  2.    Code
  3.    From DSL like specification
  4.    All of the above
Explanation:-
Answer: Option D. -> All of the above





Question 6. Mention the features offered by groovy JDK.
  1.    The collection of literals. The literal syntax and its initialization are natural and highly readable unlike java in which they are cumbersome and unpleasant.
  2.    The Groovy Beans property. Although Java is based on the concept of JavaBeans as a structure, still it lacks a direct syntactic support. Whereas, groovy can declare a field as a property as trivial and can access it too.
  3.    This feature was presented in groovy since its first release especially in the collection framework.
  4.    All of these
Explanation:-
Answer: Option D. -> All of these





Question 7. You write a web application and build it by the Gradle build tool. When you see all Gradle tasks, there isn't task 'war'. What a problem may it be?
  1.    You forget to set plugin 'jar' in build.xml
  2.    You forget to set plugin 'war' in build.gradle
  3.    You forget to set plugin 'web' in build.gradle
  4.    You forget to set plugin 'war' in web.xml
Explanation:-
Answer: Option A. -> You forget to set plugin 'jar' in build.xml





Question 8. Explain GroovyDoc comment?
  1.    Type definitions (classes, interfaces, enums, annotations)
  2.    Fields and properties definitions
  3.    Methods definitions
  4.    All the above
Explanation:-
Answer: Option D. -> All the above





Question 9. What are Bitwise Operators in Groovy?
  1.    &: bitwise and"
  2.    I : bitwise or"
  3.    A : bitwise xor"
  4.    ~ : bitwise negation
Explanation:-
Answer: Option D. -> ~ : bitwise negation





Question 10. Why Use Groovy?
  1.    For Java programmers it provides familiar syntax
  2.    It has a rich stock of Java Libraries
  3.    It easily integrate with your existing infrastructure like Servlet Containers, App Servers, Loads of databases with JDBC drivers
  4.    All the above
Explanation:-
Answer: Option D. -> All the above