Skip to content
Sharp

Core Java · interview question

If a method signature changes from using primitive int to Integer, what potential issue might arise?

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

Correct answer

C. NullPointerException

Why

Changing from int to Integer allows for null values, which can lead to NullPointerException if null is passed to a part of the code that expects a non-null value.

Test yourself on Core Java

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

Start free test
All Core Java questions →