← 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?
- A.It causes a compile error
- B.It rejects zero
- C.A primitive int can never be null, so the rule never fails; use @Min or an Integer
- 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 →