Spring Questions and Answers – JSON with REST

This set of Java Spring Questions and Answers for experienced focuses on “JSON with REST”.

1. Payload format for REST services.
a) RSS
b) Atom
c) JSON
d) All of the mentioned
View Answer

Answer: d
Explanation: JSON, in addition to RSS and Atom, has blossomed into a favorite payload format for REST services.

2. All REST service payloads rely on XML markup.
a) True
b) False
View Answer

Answer: b
Explanation: JSON is different in the sense that its content is a special notation based on the JavaScript language.

3. Class that forms part of Spring to apply JSON content.
a) MappingJacksonJsonView
b) MappingJsonView
c) MappingJacksonJson
d) JsonView
View Answer

Answer: a
Explanation: In addition to relying on Spring REST support, we will also use the MappingJacksonJsonView class that forms part of Spring to facilitate the publication of JSON content.
advertisement
advertisement

4. The MappingJacksonJsonView class depends on Jackson JSON processor library.
a) org.codehaus.jackson
b) jackson-mapper-asl
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: a
Explanation: The MappingJacksonJsonView class depends on the presence of the Jackson JSON processor library which can be downloaded at http://wiki.fasterxml.com/JacksonDownload.

5. Information you wish to publishas a JSON Object can be located in a RDBMS or text file, accessed through JDBC or ORM.
a) True
b) False
View Answer

Answer: a
Explanation: This information can be located in a RDBMS or text file, accessed through JDBC or ORM, inclusively be part of a Spring bean or some other type of construct.

6. JSON payload consists of text and separators like.
a) { , }
b) ( , )
c) :
d) All of the mentioned
View Answer

Answer: d
Explanation: a JSON payload consists of text and separators like { , }, ( , ), : and “.

7. To access JSON in a Spring application, library used is:-
a) JSON-LIB
b) SpringJSON-lib
c) JSON-lib
d) None of the mentioned
View Answer

Answer: a
Explanation: Though it’s technically possible to access JSON in a Spring application (i.e., on the server side), using a third-party Java library like JSON-LIB (http://json-lib.sourceforge.net/ ).
advertisement

8. You are often better served accessing and manipulating REST services with XML payloads in Spring applications.
a) True
b) False
View Answer

Answer: a
Explanation: The Java platform’s native support for XML, in addition to the fact that XML is more intuitive and does not have the same processing limitations as browsers.

9. Class which is capable of performing a multitude of operations on REST services.
a) RestTemplate
b) XPathTemplate
c) XMLTemplate
d) JavaTemplate
View Answer

Answer: a
Explanation: Spring RestTemplate class is capable of performing a multitude of operations on REST services in order for their payloads to be used inside Spring applications, processing elaborate XML responses requires using a set of approaches beyond those of this last class.
advertisement

10. XML query language for selecting nodes from an XML document.
a) XPathTemplate
b) XPath
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: b
Explanation: XPath—an XML query language for selecting nodes from an XML document— knowledge about Spring HttpConverterMessage, as well as supporting facilities like Spring XPathTemplate.

11. The Handler method assigns the returning XML payload to a String.
a) True
b) False
View Answer

Answer: a
Explanation: The handler method makes use of the getForObject method of the RestTemplate class and assigns the returning XML payload to a String, which is then added to the handler method Model object.

12. To extract and manipulate payloads in Spring REST in a format other than String.
a) HttpConverter
b) HttpMessage
c) HttpConverterMessage
d) None of the mentioned
View Answer

Answer: c
Explanation: All objects that are returned and inclusively passed to the methods belonging to the RestTemplate class are converted to and from HTTP messages using a class which implements the HttpConverterMessage interface.

13. To write your own converters relying on the MarshallingHttpMessageConverter interface that would allow the use of custom marshallers.
a) messageConverters
b) messageConvert
c) converters
d) convertersMessage
View Answer

Answer: a
Explanation: Using custom converters requires registering them with the messageConverters bean property in a Spring application.

14. To override the default implementations registered with the RestTemplate class.
a) messageConverters
b) messageConvert
c) converters
d) convertersMessage
View Answer

Answer: a
Explanation: It’s also possible to override the default implementations registered with the RestTemplate class using the same messageConverters bean property.

15. To extract and manipulate the contents of a REST service payload.
a) messageConverters
b) StreamSource class
c) converters
d) convertersMessage
View Answer

Answer: b
Explanation: It becomes easier to extract and manipulate the contents of a REST service payload since it can be done through the more flexible StreamSource class.

Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring for Experienced, 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.