Bird
0
0

Which of the following is the correct way to create a Jackson ObjectMapper instance in Spring Boot?

easy📝 Syntax Q3 of 15
Spring Boot - Request and Response Handling
Which of the following is the correct way to create a Jackson ObjectMapper instance in Spring Boot?
AObjectMapper mapper = new Jackson();
BObjectMapper mapper = new ObjectMapper();
CObjectMapper mapper = ObjectMapper.create();
DObjectMapper mapper = ObjectMapper.getInstance();
Step-by-Step Solution
Solution:
  1. Step 1: Recall ObjectMapper instantiation

    Jackson's ObjectMapper is instantiated with new ObjectMapper().
  2. Step 2: Check other options for validity

    Other methods like create() or getInstance() do not exist in Jackson API.
  3. Final Answer:

    Use new ObjectMapper() to create an instance -> Option B
  4. Quick Check:

    Create ObjectMapper = new ObjectMapper() [OK]
Quick Trick: Instantiate ObjectMapper with new ObjectMapper() [OK]
Common Mistakes:
  • Using non-existent factory methods
  • Confusing with singleton patterns
  • Trying to call Jackson() constructor

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes