Java Spring Questions and Answers for experienced on “JSON with REST”.
1. Payload format for REST services.
a) RSS
b) Atom
c) JSON
d) All of the mentioned
Answer: d
Clarification: 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
Answer: b
Clarification: 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
Answer: a
Clarification: 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.
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
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: d
Clarification: 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
Answer: a
Clarification: 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/ ).
8. You are often better served accessing and manipulating REST services with XML payloads in Spring applications.
a) True
b) False
Answer: a
Clarification: 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
Answer: a
Clarification: 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.
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
Answer: b
Clarification: 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
Answer: a
Clarification: 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
Answer: c
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: b
Clarification: 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.
Java Spring for Experienced,