Spring Questions and Answers – Application’s Domain Classes

«
»

This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses on “Application’s Domain Classes”.

1. Classes used to describe an application’s primary elements.
a) Domain Classes
b) Application
c) Context
d) View
View Answer

Answer: a
Explanation: Domain classes are used to describe an application’s primary elements and characteristics.
advertisement

2. In web applications, domain classes are generally the first things to be defined.
a) True
b) False
View Answer

Answer: a
Explanation: 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/
View Answer

Answer: b
Explanation: 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
View Answer

Answer: b
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: a
Explanation: In addition, corresponding unit tests files are also generated for each domain class under an application’s test/unit directory.
advertisement

7. Static field which defines constraints on the domain class.
a) static{}
b) static field{}
c) static constraint{}
d) static constraints{}
View Answer

Answer: d
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: c
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: d
Explanation: Four views are created corresponding to a controller class’s CRUD operations named create.gsp, edit.gsp, list.gsp, and show.gsp.
advertisement

13. .gsp extension stands for:-
a) Groovy Server Pages
b) Groovy Service Pages
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: a
Explanation: .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
View Answer

Answer: d
Explanation: 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
View Answer

Answer: c
Explanation: You can start the Grails application using grails run-app and work as an end user with the application.

Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn