GROOVY Questions and Answers

List out the differences between Groovy and Java?

  • All the packages and classes in Groovy is imported by default, you do not have to use the import statement explicitly
  • Unlike Java where the methods are chosen at compile time, the methods in the Groovy are chosen based on the types of arguments at runtime
  • In {…} block is reserved for closures, which means that you cannot build array literals with this syntax
  • Like in Java, omitting a modifier on a field does not result in a package private field
  • Automatic Resource Management or ARM block from java 7 are not supported in Groovy
  • Java 8 lambdas are more or less considered as anonymous inner classes, and Groovy does not support that syntax