🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: REST APIs: all 10 questions

Quiz: REST APIs · Question 5 of 10

Why return DTOs instead of JPA entities from controllers?

Why return DTOs instead of JPA entities from controllers?

  1. A.Entities cannot be converted to JSON at all
  2. B.DTOs control exactly what is exposed and avoid leaking internals or relationship loops
  3. C.DTOs make the database faster
  4. D.Spring requires records in controllers
Answer & explanation

Correct answer: DTOs control exactly what is exposed and avoid leaking internals or relationship loops

The API contract stays stable even when the entity changes.

Can you get the rest right without peeking?

Take the timed Quiz: REST APIs quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →