Explore topic-wise InterviewSolutions in Current Affairs.

This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.

1.

How Do You Use Pessimist Looking In A Domain Class?

Answer»

Call ".lock()" METHOD on domain instance.

Example.

def airport = Airport.get(10)
airport.lock() // lock for update
airport.name = "Heathrow"
airport.save()
 
or defining in your domain CLASS "version= false"
Example:
class Person {

static MAPPING = {
version false // here you disability OPTIMIST looking
autoTimestamp false
}
}

Call ".lock()" method on domain instance.

Example.

def airport = Airport.get(10)
airport.lock() // lock for update
airport.name = "Heathrow"
airport.save()
 
or defining in your domain class "version= false"
Example:
class Person {

static mapping = {
version false // here you disability optimist looking
autoTimestamp false
}
}

2.

What Is Pessimistic Locking.

Answer»

Locking a ROW until the CURRENT transaction is COMPLETED. This has the implication that other read OPERATIONS will be blocking until the LOCK is released.

Locking a row until the current transaction is completed. This has the implication that other read operations will be blocking until the lock is released.

3.

What Type Of Looking Is By Default In Grails Optimistic Or Pessimist Looking?

Answer»

optimistic LOOKING: Optimistic locking is a feature of HIBERNATE which involves storing a VERSION VALUE in a special version column in the database that is incremented after each update.

optimistic looking: Optimistic locking is a feature of Hibernate which involves storing a version value in a special version column in the database that is incremented after each update.

4.

Could You Give Me An Example Of Methaprogramming In Grails?

Answer»

The DYNAMIC FINDERS in the DOMAINS CLASS.

The dynamic finders in the domains class.

5.

What Is Methaprogramming?

Answer»

It's the groovy ABILITY to add new methods or VARIABLES to classes dynamically at RUN time, and WITHOUT torching the CODE.

It's the groovy ability to add new methods or variables to classes dynamically at run time, and without torching the code.

6.

What Do You Have To Do If You Don't Want That A Property Of Your Domain Be Mapped To The Db?

Answer»

In your DOMAIN CLASS:

STATIC TRANSIENT['cant SAVE this']

In your domain class:

static transient['cant save this']

7.

What Is The Difference Between Buildconfig.groovy And Config.groovy?

Answer»

that Config INCLUDE configuration NEEDED to RUN your application and BuildConfig include configuration to build and DEPLOY your application.

that Config include configuration needed to run your application and BuildConfig include configuration to build and deploy your application.

8.

Where Do You Setup Your Dependency Manager, Your Repositories, Dependencies And Pluguins?

Answer»

BuildConfing.groovy

BuildConfing.groovy

9.

Where Do You Setup Your Db , Hibernate Version And Environments?

Answer»

DataSource.groovy

DataSource.groovy

10.

What Is The Command To Create The Integration Test Of A Domain Class?

Answer»

GRAILS create-integration-test "packpage"+"DOMAIN CLASS"

grails create-integration-test "packpage"+"domain class"

11.

What Is The Command To Create The Unit Test Of A Domain Class?

Answer»

GRAILS create-unit-test "packpage"+"DOMAIN CLASS"

grails create-unit-test "packpage"+"domain class"

12.

What Is The Command To See Your Grails Version?

Answer»

GRAILS -VERSION

grails -version

13.

What Is The Command To Rerun Test In Your Application?

Answer»

GRAILS test-app --RERUN

grails test-app --rerun

14.

What Is The Command To Test Your Application For Integration Test Only?

Answer»

GRAILS test-app --INTEGRATION

grails test-app --integration

15.

What Is The Command To Test Your Application For Unit Test Only?

Answer»

GRAILS test-app --UNIT

grails test-app --unit

16.

What Is The Command To Test Your Application?

Answer»

GRAILS test-app

grails test-app

17.

What Is The Command To Stop Your Application?

Answer»

GRAILS stop-app

grails stop-app

18.

What Is The Command To Generate The Static Scaffolding Of The Controllers And Views Of All Your Domain Classes?

Answer»

GRAILS generate-all "*"

grails generate-all "*"

19.

What Is The Command To Generate The Static Scaffolding Of The Controllers And Views Of A Domain Class?

Answer»

GRAILS generate-all "packpage"+"DOMAIN CLASS"

grails generate-all "packpage"+"domain class"

20.

What Is The Command To Do Static Scaffolding Of The View Of A Domain?

Answer»

GRAILS generate-views "packpage"+"DOMAIN CLASS"

grails generate-views "packpage"+"domain class"

21.

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

Answer»

GRAILS generate-controller "packpage"+"DOMAIN CLASS"

grails generate-controller "packpage"+"domain class"

22.

What Is The Command To Run You Application In A Different Port That 8080?

Answer»

GRAILS -Dserver.port=9090 run-app

grails -Dserver.port=9090 run-app

23.

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

Answer»

GRAILS -Dgrails.env=test run-app

grails -Dgrails.env=test run-app

24.

What Is The Command To Generate A War File?

Answer»

GRAILS WAR

grails war

25.

What Are The Default Environments In Grails?

Answer»

DEVELOPMENT, TEST And PRODUCTION

Development, Test And Production

26.

What Is The Command To Create A Controller?

Answer»

GRAILS create-controller "packpage" +"NAME of your DOMAIN CLASS"

grails create-controller "packpage" +"name of your domain class"

27.

What Is The Command To Create A Domain Class?

Answer»

GRAILS create-DOMAIN-CLASS "packpage" +"NAME of your domain class"

grails create-domain-class "packpage" +"name of your domain class"

28.

What Is The Command To Run A Grails Application?

Answer»

GRAILS run-app

grails run-app

29.

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

Answer»

GRAILS create-APP "the NAME of your app"

grails create-app "the name of your app"

30.

What Is Gorm?

Answer»

GORM is Grails' object relational mapping (ORM) implementation. Under the hood it uses Hibernate (a very popular and flexible OPEN source ORM solution) and thanks to the dynamic nature of Groovy with its STATIC and dynamic typing, along with the convention of Grails, there is far less configuration INVOLVED in creating Grails domain classes.

GORM is Grails' object relational mapping (ORM) implementation. Under the hood it uses Hibernate (a very popular and flexible open source ORM solution) and thanks to the dynamic nature of Groovy with its static and dynamic typing, along with the convention of Grails, there is far less configuration involved in creating Grails domain classes.

31.

What Is Orm?

Answer»

means OBJECT relational mapping, A SIMPLE answer is that you wrap your tables or stored procedures in classes in your programming language, so that instead of writing SQL statements to interact with your database, you use METHODS and properties of objects.

It's a library or framework that help you to map/convert your models in to tables in your database, It's like a mediator or an intermediate that avoid that you have to write SQL code and allows you to interact with the DB using a programming language like groovy without have to worry about write SQL code or what kind of database are you using, you can switch from mySql to Oracle DB modifying only 4 lines of code, an example of what is an ORM It's the Hibernate Framework.

means object relational mapping, A simple answer is that you wrap your tables or stored procedures in classes in your programming language, so that instead of writing SQL statements to interact with your database, you use methods and properties of objects.

It's a library or framework that help you to map/convert your models in to tables in your database, It's like a mediator or an intermediate that avoid that you have to write SQL code and allows you to interact with the DB using a programming language like groovy without have to worry about write SQL code or what kind of database are you using, you can switch from mySql to Oracle DB modifying only 4 lines of code, an example of what is an ORM It's the Hibernate Framework.

32.

What Is Grails?

Answer»

Grails is an open source web application framework that uses the Groovy and Java as programming language, this framework use another frameworks LIKE SPRING, Hibernate, SiteMesh and have and embebed H2 database, Tomcat server and ORM(GORM). this framework follow some design patters as Model VIEW Controller(MVC), Convention Over Configuration(CoC), Don't REPEAT yourself(DRY) and runs over the Java Virtual Machine(JVM).

Grails is an open source web application framework that uses the Groovy and Java as programming language, this framework use another frameworks like Spring, Hibernate, SiteMesh and have and embebed H2 database, Tomcat server and ORM(GORM). this framework follow some design patters as Model View Controller(MVC), Convention Over Configuration(CoC), Don't repeat yourself(DRY) and runs over the Java Virtual Machine(JVM).

33.

Explain What Is Expandometaclass In Groovy?

Answer»

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

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

34.

Explain How Groovy String Is Expressed?

Answer»

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)

Groovy string is referred as Gstring.

35.

Mention What Is The License For Groovy?

Answer»

GROOVY DEPEND at runtime on the ASM LIBRARY as well as JAVA 1.4 and the Groovy jar.

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

36.

Explain How You Can Include A Groovy Script In Another Groovy?

Answer»

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

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

37.

Explain How You Can Add Stuff To The Classpath When Running Things In Groovy Or Groovysh?

Answer»

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.

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.

38.

Explain What Is Groovysh?

Answer»

Groovysh is a command line application that enables an EASY access to evaluate Groovy expressions, DEFINE CLASSES and RUN experiments.

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

39.

Mention What Is The Role Of Closure And Listeners In Groovy?

Answer»

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.

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.

40.

Explain Groovydoc Comment?

Answer»

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

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

41.

Mention What Are Some Features Does Groovy Jdk Offers?

Answer»

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

Groovy has added new methods compare to old version like

42.

Explain The Role Of Grape Dependency In Groovy?

Answer»

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.

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.

43.

Explain How Scripts Are Run In Groovy?

Answer»

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.

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.

44.

Explain What Does The Jsonslurper Class Indicates?

Answer»

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.

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.

45.

I Get Errors When Trying To Run Groovy, Groovysh Or Groovyconsole. Whats Wrong?

Answer»

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.

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.

46.

What Is The Limitation Of Groovy?

Answer»
  • 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

47.

How Can I Add Stuff To The Classpath When Running Things In Groovysh Or Groovy?

Answer»

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.

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.

48.

When “propertymissing (string)” Method Is Called?

Answer»

The “propertyMissing (STRING)” METHOD is CALLED when no GETTER method for a given PROPERTY can be detected by the Groovy runtime.

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

49.

What Is The Licence For Groovy?

Answer»

Groovy is open SOURCE using a BSD / APACHE STYLE licence

Groovy is open source using a BSD / Apache style licence

50.

Why Use Groovy?

Answer»
  • 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