Java Spring Multiple Choice Questions & Answers (MCQs) on “Application’s Domain Classes”.
1. Classes used to describe an application’s primary elements.
a) Domain Classes
b) Application
c) Context
d) View
Answer: a
Clarification: Domain classes are used to describe an application’s primary elements and characteristics.
2. In web applications, domain classes are generally the first things to be defined.
a) True
b) False
Answer: a
Clarification: Domain classes represent data that is saved for posterity—in a permanent storage system—so it interacts with controllers, as well as representing data displayed in views.
3. In Grails, domain classes are placed under:-
a) /grails-app/WEB-INF/
b) /grails-app/domain/
c) /grails-app/domain/WEB-APP
d) /grails-app/
Answer: b
Clarification: In Grails, domain classes are placed under the /grails-app/domain/ directory.
4. The creation of domain classes by executing a simple command which is:-
a) grails create-domain-class
b) grails create-domain-class domain class name
c) domain class name
d) none of the mentioned
Answer: b
Clarification: The creation of domain classes, like most other things in Grails, can be carried out by executing a simple command in the following form:
grails create-domain-class domain class name
5. The command domain class name in creation of domain classes generates a file named domain class name.groovy.
a) True
b) False
Answer: a
Clarification: It generates a skeleton domain class file named domain class name.groovy inside the /grails-app/domain/ directory.
6. Corresponding unit tests files are also generated for each domain class while creating domain classes.
a) True
b) False
Answer: a
Clarification: In addition, corresponding unit tests files are also generated for each domain class under an application’s test/unit directory.
7. Static field which defines constraints on the domain class.
a) static{}
b) static field{}
c) static constraint{}
d) static constraints{}
Answer: d
Clarification: static constraints = { }, defines constraints on the domain class.
8. Declaration name which indicates that object’s name field can’t be blank.
a) blank:false
b) blank:true
c) all of the mentioned
d) none of the mentioned
Answer: a
Clarification: The declaration name(blank:false) indicates that a Player object’s name field cannot be left blank.
9. A variety of constraints can be used to enforce a domain class’s structure.
a) True
b) False
Answer: a
Clarification: Under certain circumstances, if a constraint is too elaborate, it’s often incorporated within an application’s controller prior to creating an object of a certain domain class.
10. Command to generate the corresponding CRUD controller and views for an application’s domain class.
a) grails create-domain-class domain class name
b) grails create-domain-class
c) grails generate-all domain class name
d) none of the mentioned
Answer: c
Clarification: You can execute the following command to generate the corresponding CRUD controller and views for an application’s domain class:
grails generate-all domain class name.
11. Grails is capable of inspecting an application’s domain classes and generating the corresponding controllers and views.
a) True
b) False
Answer: a
Clarification: Grails is capable of inspecting an application’s domain classes and generating the corresponding controllers and views necessary to create, read, update, and delete instances belonging to an application’s domain classes.
12. Views corresponding to a controller class’s CRUD operations.
a) create.gsp
b) edit.gsp
c) list.gsp
d) all of the mentioned
Answer: d
Clarification: Four views are created corresponding to a controller class’s CRUD operations named create.gsp, edit.gsp, list.gsp, and show.gsp.
13. .gsp extension stands for:-
a) Groovy Server Pages
b) Groovy Service Pages
c) All of the mentioned
d) None of the mentioned
Answer: a
Clarification: .gsp extension stands for “Groovy Server Pages,” which is equivalent to JavaServer Pages except it uses Groovy to declare programmatic statements instead of Java.
14. Views are placed under which directory:-
a) app/views/
b) app/
c) grails-app/views/WEB-INF
d) grails-app/views/domain class
Answer: d
Clarification: These views are placed under an application’s grails-app/views/domain class directory.
15. Command to start the Grails application:-
a) grails run
b) grails start-app
c) grails run-app
d) none of the mentioned
Answer: c
Clarification: You can start the Grails application using grails run-app and work as an end user with the application.