🎙 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 6 of 10

Why is @NotNull on a primitive int fee field pointless?

Why is @NotNull on a primitive int fee field pointless?

  1. A.It causes a compile error
  2. B.It rejects zero
  3. C.A primitive int can never be null, so the rule never fails; use @Min or an Integer
  4. D.It makes the field optional
Answer & explanation

Correct answer: A primitive int can never be null, so the rule never fails; use @Min or an Integer

Missing JSON numbers become 0 for an int, which @NotNull cannot catch.

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 →