+91 90691 39140 | +1 253 214 3115 | info@hub4tech.com | hub4tech

Top 20 Most Asked Apache Groovy Interview Questions and Answers

Fri, 2017-10-13 18:07
Apache Groovy

Are you preparing for Apache Groovy job interview and wondering what questions you might be asked? In this blog we have hand-picked the questions you are likely to be asked in Apache Groovy job interview and provided to-the-point answers to each one of them so as to help you prepare better for Apache Groovy job interviews.

Always keep in the mind that, only academic knowledge is not enough to crack an interview. Employers expects from the candidate to have practical knowledge and hands-on experience as well. This Apache Groovy Interview Questions designed by industry expert will help you to gain practical knowledge of SAP Security.

Apache Groovy Interview Questions and Answers

  1. Explain what is Groovy?

Groovy is an object-oriented programming language for JVM (Java Virtual Machines). It is used to combine Java modules, to write Java application and to extend existing Java application.

  1. What are the dependencies for Groovy?

As well as Java 1.4 and the Groovy jar we also depend at runtime on the ASM library.

  1. What relational operators is used for in Groovy?

Relational operators allows you to compare between objects, to check whether the two objects are different or same or if one is less than, greater than or equal to others.

  1. Things work if I use Suns conventions and put { on the same line, but if I add a new line things break?

When using closures with method calls we have some syntax sugar in Groovy which is sensitive to white space (newlines to be precise). Please see this description in common gotchas for a full description.

  1. 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,
  • Completely Object Oriented
  • It possesses a reusable and assignable pieces of code
  • Operators can be overloaded
  • Literal declaration for maps, arrays, ranges and regular expressions
  • It has efficient object navigation
  1. What is the licence for Groovy?

Groovy is open source using a BSD / Apache style licence

  1. When “propertyMissing (String)” method is called?

The “propertyMissing (String)” method is called when no getter method for a given property can be detected by the Groovy runtime.

  1. How can I add stuff to the classpath when running things in groovysh or groovy?

You can add things to your $CLASSPATH environment variable. Another popular option is to create a .groovy/lib directory in your home directory and add whatever jars you want to be available by default. e.g. if you wish to connect to your favourite JDBC database and do some scripting with it then add your JDBC driver to ~/.groovy/lib.

  1. What is the limitation of Groovy?


  • Groovy can be slower
  • Groovy might need lots of memory
  • Groovy start up time requires improvement
  • It requires Java knowledge
  • It takes sometimes to get use to like New Syntax, closures, default typing,
  • Documentation is thin
  1. I get errors when trying to run groovy, groovysh or groovyConsole. Whats wrong?

Groovy depends on JDK 1.4 or later. Common errors people have when trying to run Groovy is that there’s an old groovy jar on the CLASSPATH somewhere (have you checked in java/lib/ext?) or that JAVA_HOME points to an old JDK before JDK 1. For more help please see this description of running Groovy code.

  1. Explain what does the JsonSlurper class indicates?

The JsonSlurper is a class that parses JSON text or reader content into Groovy data structures (objects) such as lists, maps, and primitive types like double, Boolean, string and Integer.

  1. Explain how Scripts are run in Groovy?

Groovy supports plain script; it does not require a class declaration. At the front of the script, imports are supported at the same way that it can be at the front of a class. In Groovy, you have to use word def to declare a function outside of a class.

  1. Explain the role of Grape dependency in Groovy?

Grape is a JAR dependency manager included into Groovy. It allows you to add quickly maven repository dependencies to your classpath, making scripting easier. The simplest use is adding an annotation to your script.

  1. What are some features does Groovy JDK offers?

Groovy has added new methods compare to old version like
Various array types and object streams with newly Groovy oriented methods like Object.every(), Object.each() etc. and also include new features like “String BufferedReader.getText()” and “InputStream.eachLine(Closure)”.

  1. Explain GroovyDoc comment?

Like multiline comments, GroovyDoc comments are multiline but it starts with a /** and end with */. Those comments are related with

  • Type definitions (classes, interfaces, enums, annotations)
  • Fields and properties definitions
  • Methods definitions
  1. What is the role of closure and listeners in Groovy?

Groovy does not support anonymous inner classes; it is possible to determine action listeners inline through the means of closures. In Groovy, listeners closure are used as a ListenerAdapter where only one method of interest is overridden.

  1. Explain what is Groovysh?

Groovysh is a command line application that enables an easy access to evaluate Groovy expressions, define classes and run experiments.

  1. Explain how you can add stuff to the classpath when running things in groovy or groovysh?

You can add things to your $CLASSPATH environment variable. Another possibility is to build a .groovy/lib directory in your home directory and append whatever jars you want to be available by default.

  1. Explain how you can include a groovy script in another groovy?

You can include a groovy script with another groovy by using the following code. When put this code at the top of the script it will bring in the contents of a groovy file.
Evaluate(new file(“../tools/Tools.groovy”))

  1. What is the license for Groovy?

Groovy depend at runtime on the ASM library as well as Java 1.4 and the Groovy jar.

Hub4tech is a one of the few online training platforms who provide best in quality and cutting edge technology education directly from industry experts. If you have any query regarding the data scientist or any of the blog information, please speak to our specialists here.

You can also send your query in our mail box at info@hub4tech.com, and we will write back or call back to you. Don’t forget to like our Facebook and LinkedIn page to get more technology updates. You can read all our Blogs here.

You can also check your level by participating in our free Online Assessment Tests

Use Full Link for Online Training and Certification

Hitesh Patel
Copyright ©2015 Hub4Tech.com, All Rights Reserved. Hub4Tech™ is registered trademark of Hub4tech Portal Services Pvt. Ltd.
All trademarks and logos appearing on this website are the property of their respective owners.