Olete.in
Articles
Mock Tests
🧪 Apache Groovy MCQ Quiz Hub
Groovy MCQ
Choose a topic to test your knowledge and improve your Apache Groovy skills
1. What is the limitation of Groovy?
Groovy can be slower
Groovy might need lots of memory
Groovy start up time requires improvement
All of the above
2. 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?
def age = params.age ?: 0
def age = params.age ? params.age : 0
def age = params.name == 'age' ? params.age : "not found"
def age = params.getAge
3. How Groovy string is expressed?
It is surrounded by double quotes, for regular strings it uses single quotes
It may contain Groovy Expressions noted in ${}
Square bracket syntax may be applied like charAt(i)
All of these
4. How can we build AST (Abstract Syntax Trees) in Groovy from string?
Strings
Code
From DSL like specification
All of the above
5. Explain GroovyDoc comment?
Type definitions (classes, interfaces, enums, annotations)
Fields and properties definitions
Methods definitions
All the above
6. . Why Use Groovy?
For Java programmers it provides familiar syntax
It has a rich stock of Java Libraries
It easily integrate with your existing infrastructure like Servlet Containers, App Servers, Loads of databases with JDBC drivers
All the above
7. What are Bitwise Operators in Groovy?
bitwise and"
I : bitwise or"
A : bitwise xor"
~ : bitwise negation
8. 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?
You forget to set plugin 'jar' in build.xml
You forget to set plugin 'war' in build.gradle
you forget to set plugin 'web' in build.gradle
You forget to set plugin 'war' in web.xml
9. Mention the features offered by groovy JDK.
The collection of literals. The literal syntax and its initialization are natural and highly readable unlike java in which they are cumbersome and unpleasant.
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 an
This feature was presented in groovy since its first release especially in the collection framework.
All of these
10. What are the advantages of groovy?
Operator overloading is also possible in this
Maps, arrays, ranges, and regular expressions can be literally declared
It possesses efficient object navigation
All of the above
11. How Is Groovy string expressed?
It is surrounded by double quotes, for regular strings it uses single quotes
It may contain Groovy Expressions noted in ${}
Square bracket syntax may be applied like charAt(i)
All of the above
12. What are the limitations of Groovy?
For using groovy, you need to have enough knowledge of Java. Knowledge of Java is important because half of groovy is based on Java
It might take you some time to get used to the usual syntax and default typing
It consists of thin documentation
All of the above
13. What are the features of groovy JDK?
This feature was presented in groovy since its first release especially in the collection framework
GDK enhancements. Many operators for many of the classes and various additional methods have also been introduced by groovy
Both of these
none of these
14. How can we build AST (Abstract Syntax Trees) in Groovy from a string?
Strings
Code
From DSL like specification
All of these
15. AST in Groovy can be built from
Strings
Codes
DSL
All of the above
16. What is Groovydoc Comment?
Type definitions (classes, interfaces, enums, annotations)
Fields and properties definitions
Methods definitions
All of the above
17. What does JVM stand for?
Java Value-based Machine
Java Virtual Machine
JavaScript Virtual Machine
JavaScript Value-based Machine
18. Following the assignment def x = 2/3; what it the type of variable x?
Integer
Rational
BigInteger
BigDecimal
19. Which tool provides a GUI for writing simple Groovy programs?
Groovysh
GroovyConsole
Groovy
None
20. Which tool provides a GUI for writing simple Groovy programs?
Groovysh
GroovyConsole
Groovycorrect
Nonewrong
21. Groovy is based on
Java
JavaScript
Python
Ruby
22. Groovy is a high-level language
True
False
Error
Can not say
23. Groovy is
Dynamically typed language
Statically typed language
Optionally typed (Both dynamic and static)
None of these
24. In static programming languages
type checking happens at run time
type checking happens at compile time
both (a) and (b)
None of These
25. In Groovy map, each element will be mapped to a A. B. C.
ID
Value
Key
None of These
26. Groovy can be used as a scripting language.
False
True
Error
None of These
27. What will be the output for the following code? def example = 1..100 println(example.getTo())
1
99
100
None of these
28. In groovy all methods and classes are--------------by default A. B. C.
Private
Public
Protected
None
29. AST in Groovy can be built from…
Strings
Codes
DSL
None of These
30. Which of the following is a reason why programmers use Groovy?
It is fast and easy
It requires a small portion of memory
Documentation is thin
Operators can be overloaded
31. Groovy is an object oriented programming language for
JVM
HTML
PHP
Python
32. All of the following are uses of Groovy except…
To combine Java modules
To write Java application
To extend existing Java applications
To execute Java applications
33. What term do you use in Groovy to declare a function outside a class?
Div
Class
Def
Function
34. Groovy does not require…
Large memory
Java knowledge
Syntaxes
Class declaration
35. What is the limitation of Groovy?
Groovy can be slower
Groovy might need lots of memory
Groovy start up time requires improvement
All of the above
36. How can we build AST (Abstract Syntax Trees) in Groovy from string?
Strings
Code
From DSL like specification
All of the above
37. What is the command to run a groovy file from the command line
groovy “location of file”
groovy run “location of file”
both (a) and (b)
None of these
38. How to use single line comments in groovy
// comment
# comment
$ comment
All of the above
Submit