Skip to content
Sharp

Core Java · interview question

Which of the following is a reason to prefer using a wrapper type over a primitive type in a Java domain model?

Multiple choiceEasychapter-7-curatedpremiumcore-javawrapper-types-and-autoboxing
Choose one answer
Answer and explanation

Correct answer

B. Allows null values for optional fields

Why

Wrapper types like Integer can be null, which allows you to represent optional fields or the absence of a value, unlike primitive types which always have a default value.

Test yourself on Core Java

A free test with instant, explained results. No account needed.

Start free test
All Core Java questions →