• Tutorials
  • Courses
  • Tracks

Advanced Java Quiz Day 61

Last Updated :
Discuss
Comments

Question 1

What library is used by default in Spring Boot to handle JSON?

  • Gson

  • Jackson

  • JSON.simple

  • FastJSON

Question 2

Which Spring annotation is used to automatically convert a Java object to JSON in the response?

  • @ResponseBody

  • @RequestBody

  • @JsonSerialize

  • @PathVariable

Question 3

Which annotation in Jackson changes the JSON field name?

  • @JsonIgnore

  • @JsonInclude

  • @JsonProperty

  • @JsonField

Question 4

What happens if you return a Java object from a @RestController method?

  • It will be ignored

  • It will be automatically converted to JSON

  • It will be converted to XML

  • It will throw an error

Question 5

Which annotation is used to ignore a field during JSON serialization?

  • @JsonIgnore

  • @JsonProperty

  • @JsonInclude

  • @JsonSkip

Question 6

What does @RequestBody do?

  • Converts JSON from request into a Java object

  • Sends a file in the response

  • Maps URL variables

  • Converts a Java object to JSON

Question 7

If you use spring-boot-starter-web, which JSON library is included by default?

  • Jackson

  • Gson

  • JSON-P

  • org.json

Question 8

In a REST API, to return only non-null fields in JSON, you use:

  • @JsonIgnore

  • @JsonInclude(JsonInclude.Include.NON_NULL)

  • @JsonProperty

  • @JsonSkip

Question 9

What is the main difference between @Controller and @RestController in Spring?

  • @RestController returns JSON directly

  • @RestController is faster

  • No difference

  • @Controller is for APIs

There are 9 questions to complete.

Take a part in the ongoing discussion