1.
Groovy is an object oriented programming language for...
Correct Answer
A. JVM
Explanation
Groovy is an object-oriented programming language designed specifically for the Java Virtual Machine (JVM). It is fully compatible with Java and can be seamlessly integrated with existing Java code. Groovy leverages the JVM's capabilities and provides additional features and syntactic sugar, making it easier and more expressive to write code. It can be used for a wide range of applications, including web development, scripting, and automation, making it a versatile language for JVM-based projects.
2.
All of the following are uses of Groovy except...
Correct Answer
D. To execute Java applications
Explanation
Groovy is a dynamic programming language that runs on the Java Virtual Machine (JVM). It is often used to write Java applications, extend existing Java applications, and combine Java modules. However, executing Java applications is not a specific use of Groovy. Java applications can be executed directly using the Java Virtual Machine without the need for Groovy. Therefore, the correct answer is "To execute Java applications."
3.
One of the limitations of Groovy is...
Correct Answer
B. Needs lots of money
4.
Groovy does not require...
Correct Answer
D. Class declaration
Explanation
Groovy does not require class declaration because it is a dynamic language that allows for more flexibility in coding. Unlike Java, where every piece of code needs to be inside a class, Groovy allows for loose scripting where classes can be defined on the fly. This makes it easier and faster to write code in Groovy without the need for explicit class declarations.
5.
What term do you use in Groovy to declare a function outside a class?
Correct Answer
C. Def
Explanation
In Groovy, the term "def" is used to declare a function outside a class. The "def" keyword is a shorthand for defining variables without specifying their types explicitly. It is commonly used to declare functions in Groovy, allowing for flexibility in defining functions without the need for strict typing.
6.
What does JVM stand for
Correct Answer
B. Java Virtual Machine
Explanation
JVM stands for Java Virtual Machine. It is a virtual machine that executes Java bytecode. It provides a runtime environment for Java programs to run on different platforms. JVM is responsible for converting the bytecode into machine code that can be understood by the underlying operating system. It also manages memory, handles garbage collection, and provides various other runtime services for Java applications.
7.
How can a Groovy string be expressed?
Correct Answer
A. It is surrounded by double quotes
Explanation
A Groovy string can be expressed by surrounding it with double quotes. This is the standard way of representing a string in most programming languages, including Groovy. The double quotes indicate that the content within them is a string of characters.
8.
AST in Groovy can be built from...
Correct Answer
D. All of the above
Explanation
AST in Groovy can be built from strings, codes, and DSL. AST stands for Abstract Syntax Tree, which represents the structure of a program. In Groovy, the AST can be constructed by parsing and analyzing strings, codes written in the Groovy language, or using Domain Specific Languages (DSL). All of these methods can be used to generate the AST in Groovy.
9.
Which of the following starts with a **/ and ends with */?
Correct Answer
B. GroovyDoc
Explanation
GroovyDoc starts with a /** and ends with */. This is a type of documentation comment used in the Groovy programming language. It is used to provide information and documentation about classes, methods, and variables in the code. The other options, Comments, Groovysh, and Codes, do not start with a / and end with */.
10.
Which of the following is a reason why programmers use Groovy?
Correct Answer
D. Operators can be overloaded
Explanation
Programmers use Groovy because it allows them to overload operators. Overloading operators means that programmers can define new meanings for operators such as +, -, *, etc., allowing them to perform custom operations on objects. This feature provides flexibility and expressiveness in the code, making it easier for programmers to write and understand complex operations.