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

Quiz: Validation and Errors · Question 7 of 10

Which exception does Spring throw when a @Valid @RequestBody DTO fails its constraints?

Which exception does Spring throw when a @Valid @RequestBody DTO fails its constraints?

  1. A.MethodArgumentNotValidException
  2. B.CourseNotFoundException
  3. C.NullPointerException
  4. D.IllegalStateException
Answer & explanation

Correct answer: MethodArgumentNotValidException

The advice class handles it and turns it into a 400 ProblemDetail with field errors.

Can you get the rest right without peeking?

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

Start the quiz →