Spring Questions and Answers – Custom Layouts,Tags and Templates

This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses on “Custom Layouts,Tags and Templates”.

1. A Grails view can contain:-
a) HTML Tags
b) GSP or JSTL Tags
c) Groovy or Java code
d) All of the mentioned
View Answer

Answer: d
Explanation: A Grails view can contain display elements (e.g., HTML tags), business logic elements (e.g., GSP or JSTL tags) or straightforward Groovy or Java code to achieve its display objectives.

2. A view can require a unique combination of display elements and business logic.
a) True
b) False
View Answer

Answer: a
Explanation: To simplify the inclusion of such a combination and facilitate its reuse in multiple views a custom tag can be used.

3. To create custom tags.
a) grails create tag
b) grails create-tag-lib tag-lib-name
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: b
Explanation: To create custom tags, you can use the grails create-tag-lib tag-lib-name command.
advertisement
advertisement

4. grails create-tag-lib tag-lib-name command creates a custom tag library under:-
a) /grails-app/tag/
b) /grails-app/
c) /grails-app/tag-lib/
d) none of the mentioned
View Answer

Answer: c
Explanation: This command creates a skeleton class for a custom tag library under an application’s /grails-app/tag-lib/ directory.

5. In order for this custom tag to function properly in JSP, it’s necessary to add it to the corresponding Tag Library Definition (TLD) grails.tld.
a) True
b) False
View Answer

Answer: a
Explanation: TLDs are located in an application’s /web-app/WEB-INF/tld/ directory.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Custom tags can also rely on input parameters.
a) True
b) False
View Answer

Answer: a
Explanation: Custom tags can also rely on input parameters passed in as tag attributes to perform a backing class’s logic.

7. By default, Grails assigns custom tags to:-
a) g: namespace
b) f: namespace
c) j: namespace
d) all of the mentioned
View Answer

Answer: a
Explanation: Finally, a word about the namespace used in Grails custom tags—by default, Grails assigns custom tags to the g: namespace.
advertisement

8. By default, Grails applies a global layout to display an application’s content.
a) True
b) False
View Answer

Answer: a
Explanation: This allows views to have a minimal set of display elements (e.g., HTML, CSS, and JavaScript) and inherit their layout behavior from a separate location.

9. Grails doesn’t supports the concept of templates.
a) True
b) False
View Answer

Answer: b
Explanation: Grails also supports the concept of templates, which serve the same purpose as layouts, except applied at a more granular level. In addition, it’s also possible to use templates for rendering a controller’s output, instead of a view as in most controllers.
advertisement

10. Where is subdirectory called layouts located, containing the layouts available to an application?
a) /grails-app/view/
b) /grails-app/
c) /grails-app/view/WEB-INF
d) none of the mentioned
View Answer

Answer: a
Explanation: Inside the /grails-app/view/ directory of an application, you can find a subdirectory called layouts, containing the layouts available to an application.

11. Tag is used to define the contents of a layout’s title section.
a) g:layoutTitle
b) g:layoutHead
c) g:layoutBody
d) g:layoutMeta
View Answer

Answer: a
Explanation: The g:layoutTitle tag is used to define the contents of a layout’s title section.

12. Tag is used to define the contents of a layout’s head section.
a) g:layoutTitle
b) g:layoutHead
c) g:layoutBody
d) g:layoutMeta
View Answer

Answer: b
Explanation: Any values declared in the head of a view head inheriting this layout are placed in this location upon rendering.

13. Tag allows any view inheriting this layout automatic access to JavaScript libraries.
a) g:javascript library=”application”
b) g:layoutHead
c) g:layoutBody
d) g:layoutMeta
View Answer

Answer: a
Explanation: Upon rendering, this element is transformed into the following: script type=”text/javascript” src=”/court/js/application.js” /script.

14. A view’s body content is inside the:-
a) g:javascript library=”application”
b) g:layoutHead
c) g:layoutBody
d) g:layoutMeta
View Answer

Answer: c
Explanation: Grails automatically sorts out the substitution process by placing a view’s title content inside the g:layoutTitle tag, a view’s body content inside the g:layoutBody / tag, and so on.

15. GORM dynamic finder comparators:-
a) InList
b) LessThan
c) LessThanEquals
d) All of the mentioned
View Answer

Answer: d
Explanation: GORM comparator Query
InList If value is present in a given list of values
LessThan For lesser object(s) than the given value
LessThanEquals For lesser or equal object(s) than the given value
GreaterThan For greater object(s) than the given value
GreaterThanEquals For greater or equal object(s) than the given value
Like For object(s) like the given value
Ilike For object(s) like the given value in a case insensitive manner
NotEqual For object(s) not equal to the given value
Between For object(s) between to the two given values
IsNotNull For not null object(s); uses no arguments
IsNull For null object(s); uses no arguments

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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.