Skip to content
Sharp

Modern Java · interview question

Why might you choose a wrapper class like Integer over a primitive int?

Multiple choiceMediumchapter-7-curatedpremiummodern-javamodern-java-design-choices
Choose one answer
Answer and explanation

Correct answer

B. To store null values

Why

Wrapper classes like Integer can store null values, which is useful for representing the absence of a value in collections or databases. Primitives cannot hold null, which can be a limitation in some designs.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →