Grails Interview Questions for Freshers/Grails Interview Questions and Answers for Freshers & Experienced

How do I call my custom environment in Grails?

Add the grails.env system property. I.e. grails -Dgrails.env=custom run-app.

Posted Date:- 2021-12-01 08:19:13

Which environments are available by default in Grails?

Production (prod), Development ( dev ) and Test

Posted Date:- 2021-12-01 08:18:30

What happens when you call grails bug-report?

Grails generates a dehydrated timestamped minimal zip file that can be attached to JIRA reports. One way to hydrate these into full projects is to call grails upgrade on them.

Posted Date:- 2021-12-01 08:17:54

What are some things I need to be careful about when working with the Grails console?

The bootstrap files don’t get loaded. So if your database is in dbCreate = ‘create[-drop]’ mode, you might not get the same data that you would expect.The console also reloads on code change the same way that grails run-app does. So the code that you have typed in might get lost.

Posted Date:- 2021-12-01 08:17:01

How do I get a hold of my Spring beans in the Grails console?

Grails console injects a ctx variable, which represents the Spring context. You can then just use ctx.getBean( ‘myServiceName’ ) to get a hold of your beans.

Posted Date:- 2021-12-01 08:16:24

What is the difference between the Grails console, shell and interactive modes?

Grails interactive is interactive mode of the grails command line interface. It lets you run Gant scripts in the script runner one after another.

Grails console is a Swing-based command console similar to the Groovy console. It let’s you execute code against a full environment that has access to all your domain classes and quickly test out code that would go into controllers and services.

Grails shell is the headless version of Grails console. This is useful when you want to access and test out code in a remote SSH-based server. One of the advantages of the Grails shell is that it does not reload when domain classes change like the console does, so it is useful also for long-running scripts, although the new run-script command in Grails 1.3.6 might be better suited for those.

Posted Date:- 2021-12-01 08:15:46

What Is The Command To Do Static Scaffolding Of A Controller?

grails generate-controller "packpage"+"domain magnificence".

Posted Date:- 2021-12-01 08:15:08

What Is The Command To Run Your Application In A Different Environment That Development?

grails -Dgrails.Env=take a look at run-app

Posted Date:- 2021-12-01 08:13:57

What Is The Command To Create A Controller?

grails create-controller "package" +"call of your area elegance"

Posted Date:- 2021-12-01 08:13:22

What Is The Command To Create A Domain Class?

Grails create-domain-elegance "package deal" +"call of your area elegance".

Posted Date:- 2021-12-01 08:12:21

What Is The Command To Create A New Application In Grails?

grails create-app "the call of your app"

Posted Date:- 2021-12-01 08:11:53

What Is Gorm?

GORM is Grails' object relational mapping (ORM) implementation. Under the hood it makes use of Hibernate (a totally famous and bendy open source ORM solution) and thanks to the dynamic nature of Groovy with its static and dynamic typing, together with the conference of Grails, there may be far much less configuration worried in creating Grails area training.

Posted Date:- 2021-12-01 08:09:41

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.

Posted Date:- 2021-12-01 08:09:09

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.

Posted Date:- 2021-12-01 08:08:29

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.

Posted Date:- 2021-12-01 08:08:03

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.

Posted Date:- 2021-12-01 08:07:14

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

Posted Date:- 2021-12-01 08:06:28

Explain what are Bitwise Operators in Groovy?

Bitwise operators can be implemented on a BYTE or an INT and return and INT. Bitwise operators offer 4 bitwise operators

* &: bitwise “and”
* I : bitwise “or”
* A : bitwise “xor”
* ~ : bitwise negation

Posted Date:- 2021-12-01 08:05:28

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

Posted Date:- 2021-12-01 08:04:40

Explain what is Groovysh?

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

Posted Date:- 2021-12-01 08:02:58

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”))

Posted Date:- 2021-12-01 08:02:08

Explain how you can query in Groovy?

Let see a simple example of how Groovy calls out the query

import groovy.sql.sql

sql = Sql.newInstance ('jdbc: jtds: sqlserver://serverName/dbName-Class;domain=domainName','username','password','net.sourceforge.jtds.jdbc.driver')

sql.eachRow ('select * from tableName') {print "$${it.firstName} –" }

Posted Date:- 2021-12-01 08:01:36

What do you understand by metaprogramming?

Metaprogramming is the ability of adding new methods or variables to the classes dynamically at run time. You can add methods or variables whenever and wherever you want. This is a very powerful ability. Be it the use of code production, unit tests, or anything in between, these capabilities increases the curiosity of the java developers. These are the programs that write or manipulate other programs. These are responsible for dynamic string execution. These help in exposing the internal of runtime engine to the programming codes through API’s. the meta object protocols make the program semantics explicit and extensible.

Posted Date:- 2021-12-01 08:00:46

What do you mean by closures?

A closure is a short and anonymous block of code which is just used to span a few lines of code. This block of code can even be entered as a parameter in the method. Closures are anonymous in nature. Formal parameters can also be contained in closures so that it can be more useful just like methods in groovy. Closures can also refer to a variable at the time when a closure is defined. Closures can be a type of parameter for a method. Few methods provided by closure itself are listed below:

* find()
* findAll()
* any() and every()
* Collect (), etc.

Posted Date:- 2021-12-01 07:59:47

What is the use of bootstrap.groovy?

Sometimes a situation occurs in which a particular task is to be carried out every time the application starts or stops.”bootstrap.groovy” is used for this particular situation. It is a simple plain groovy script which has two important closures: the “init” and “destroy” files. So, whenever the application starts or stops, these closures are called upon respectively. This “bootstrap.groovy” is present inside the grails-app/conf folder. It is used to define a code whenever the application performs any function.

Posted Date:- 2021-12-01 07:58:57

Please explain the difference between the Config.groovy and BuildConfig.groovy files.

The Config.groovy file contains configuration properties and information needed when running your application. It contains properties used by your services, controllers, etc.

The BuildConfig.groovy file contains information relevant to building and deploying your application, such as repositories, jar file dependencies and war file name.

Posted Date:- 2021-12-01 07:58:08

Explain the concept of externalized configuration. What is this good for?

Externalized configurations let me define other config and .properties files that don’t live within the grails-app/conf directory.

To enable this, I need to define locations for the application to look for configuration files via the grails.config.locations in Config.groovy in relation to the classpath or filesystem.

Posted Date:- 2021-12-01 07:57:20

What are the best practices to be followed while developing a grails application?

Building an application using the grails framework is quite easy. But, when building it the right way we need to follow the best practices. Some of the practices followed while building a grails application are listed below:

•Controller: the controller logic should be as simple as possible. Duplication of code should be avoided.

•Service: it is the right choice for a coarse-grained code. By default, services are transactional in nature.

•Views: views should be as simple as possible. A consistent look should be maintained throughout the pages of the application.

•Internationalization: all the text messages in view should be moved to “”.

•Domain: the specific logic of the model domain should be placed in its own domain.

Posted Date:- 2021-12-01 07:56:29

How can you run Scripts in Groovy?

Doing this is not a big deal. All the plain scripts are supported and compatible with Groovy. The good thing is there is no need for the programmers to declare the class which consumes additional time. At the beginning of any script, it enables the programmers to use imports. This process is very similar to using them in a class. In case you need to declare a function outside the class, you can use the command “def”

Posted Date:- 2021-12-01 07:55:40

Tell one reason why more and more programmers are considering Groovy?

Well, the biggest reason is it can easily be integrated with the existing infrastructure. This makes Groovy one of the best and in fact, a good language that can be considered for any project. Due to the Java-based approach, programmers need not worry about compatibility issues and the good thing is one can easily keep up the pace in every situation.

Posted Date:- 2021-12-01 07:54:47

Explain the concept of thin documentation in Groovy

Well, this is actually an issue in this Object-Oriented language. The fact is it has been seen by the programmers that Groovy doesn’t provide the detailed documentation on the project or code then run on it upon request. The documentation is limited and there is no information regarding the complex and run-time errors.

Posted Date:- 2021-12-01 07:54:23

What according to you are the true reasons for the popularity of Groovy?

Well, there are certain factors that have contributed to its success. The very first thing is programmers can always make sure of a familiar syntax. This is especially for those who have a background in Java. Although Java is an old approach there is nothing wrong to say that it’s still becoming popular in every aspect. There is a very good stock of Java Libraries in Groovy and this is another important aspect for which it is quite popular. Also, it is fully Object Oriented in nature and can thus easily handle multiple tasks without any issue.

Posted Date:- 2021-12-01 07:54:00

What exactly do you know about JVM?

It stands for Java Virtual Machines. They are basically regarded as one of the essential components or requirements on which Groovy works. In fact, Groovy is largely based on these machines. This is due to the fact that Groovy needs a Java-based platform to perform its task smoothly and reliably.

Posted Date:- 2021-12-01 07:53:41

What Is Orm?

means item relational mapping, A simple solution is which you wrap your tables or saved strategies in training on your programming language, so that instead of writing SQL statements to interact together with your database, you operate techniques and residences of objects.It's a library or framework that assist you to map/convert your fashions in to tables for your database, It's like a mediator or an intermediate that avoid that you need to write SQL code and lets in you to interact with the DB using a programming language like groovy without should fear about write SQL code or what kind of database are you the use of, you can switch from mySql to Oracle DB enhancing only 4 strains of code, an instance of what's an ORM It's the Hibernate Framework.

Posted Date:- 2021-12-01 07:53:22

What Is Grails?

Grails is an open supply internet utility framework that uses the Groovy and Java as programming language, this framework use every other frameworks like Spring, Hibernate, SiteMesh and feature an embedded H2 database, Tomcat server and ORM(GORM). This framework follow a few design patterns as Model View Controller(MVC), Convention Over Configuration(CoC), Don't repeat yourself(DRY) and runs over the Java Virtual Machine(JVM).

Posted Date:- 2021-12-01 07:52:52

How could you retrieve a single value from data base using Groovy?

To recover a single value from the database you can use the command

row = sql.firstRow ('select columnA, column from tableName')

println "Row: columnA = $ {row.columnA} and column = ${row.columnB}"

Posted Date:- 2021-12-01 07:52:27

Explain how Groovy string is expressed?

Groovy string is referred as Gstring.

* 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)

Posted Date:- 2021-12-01 07:52:00

Explain what is ExpandoMetaClass in Groovy?

ExpandoMetaClass is used to add methods, properties, static methods and constructors. Expandoclass does not inherited by default; you have to call ExpandoMetaClass.enableGlobally().

Posted Date:- 2021-12-01 07:50:05

What is the license for Groovy?

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

Posted Date:- 2021-12-01 07:49:47

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.

Posted Date:- 2021-12-01 07:49:27

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.

Posted Date:- 2021-12-01 07:49:06

Mention 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)”.

Posted Date:- 2021-12-01 07:48:36

What do you mean by scaffolding? How do we use it?

Scaffolding is used to generate some basic CRUD interfaces for a domain class. It includes the necessary views and some controller actions for creating, updating, reading, and deleting CRUD operations. There are basically two types of scaffolding-

<> Static scaffolding: with the help of this, controller and views can be generated to create certain interfaces using the command line.
<> Dynamic scaffolding: using dynamic scaffolding, various functions like- index, show, edit, etc. can be dynamically implemented by default by using the runtime scaffolding mechanism.

Posted Date:- 2021-12-01 07:48:11

What are the best practices to be followed while developing a grails application?

Building an application using grails framework is quite easy. But, when building it the right way we need to follow the best practices. Some of the practices followed while building a grails application are listed below:

* Controller: the controller logic should be as simple as possible. Duplication of code should be avoided.
* Service: it is the right choice for a coarse-grained code. By default, services are transactional in nature.
* Views: views should be as simple as possible. A consistent look should be maintained throughout the pages of the application.
* Internationalization: all the text messages in view should be moved to “”.
* Domain: the specific logic of the model domain should be placed in its own domain.

Posted Date:- 2021-12-01 07:47:12

What do you understand by the concept of thin documentation in Groovy?

Thin documentation refers to a lack of proper or detailed documentation. This issue is with many Object-Oriented languages. Groovy programmers often complain about a lack of detailed documentation on the project or code. The documentation is limited in scope, and there is no information or very little information regarding the complex processes and run-time errors.

Posted Date:- 2021-12-01 07:46:23

How do I edit the web.xml file of my grails application?

First, I need to generate the template files via grails install-templates. The web.xml template will be under src/templates/war directory.

Alternatively, I could also create a plugin and use the doWithWebDescriptor method to add or remove nodes from my web.xml file.

Posted Date:- 2021-12-01 07:46:01

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.

Posted Date:- 2021-12-01 07:45:41

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

Posted Date:- 2021-12-01 07:45:26

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

Posted Date:- 2021-12-01 07:44:56

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.

Posted Date:- 2021-12-01 07:42:20

R4R Team
R4R provides Grails Freshers questions and answers (Grails Interview Questions and Answers) .The questions on website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Grails Interview Questions for Freshers,Grails Freshers & Experienced Interview Questions and Answers,Grails Objetive choice questions and answers,Grails Multiple choice questions and answers,Grails objective, Grails questions , Grails answers,Grails MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Grails fresher interview questions ,Grails Experienced interview questions,Grails fresher interview questions and answers ,Grails Experienced interview questions and answers,tricky Grails queries for interview pdf,complex Grails for practice with answers,Grails for practice with answers You can search job and get offer latters by studing .learn in easy ways .